Documentation
¶
Index ¶
- Constants
- Variables
- func Install(driver Driver) error
- func MeshSurfaceTextureFlag(slot int) uint32
- func MipLevels(width, height int) int
- func Present() error
- func ResetStatistics()
- func ResizeSurface(width, height int) error
- func SetSurfaceCornerRadius(radius int)
- func SetVSync(enabled bool)
- func Uninstall()
- type Backend
- type Blend
- type BlendFactor
- type BlendState
- type BufferMemoryStatistics
- type Color
- type Device
- func (device *Device) Activate()
- func (device *Device) BufferMemoryStatistics() BufferMemoryStatistics
- func (device *Device) Destroy()
- func (device *Device) Driver() Driver
- func (device *Device) Present() error
- func (device *Device) RendererInfo() RendererInfo
- func (device *Device) ResetStatistics()
- func (device *Device) ResizeSurface(width, height int) error
- func (device *Device) SetSurfaceCornerRadius(radius int)
- func (device *Device) SetVSync(enabled bool)
- func (device *Device) Statistics() FrameStatistics
- func (device *Device) SupportsIdleBufferTrim() bool
- func (device *Device) TrimIdleBuffers() error
- type DeviceValues
- func (values *DeviceValues[T]) Clear()
- func (values *DeviceValues[T]) Each(visit func(*Device, T) error) error
- func (values *DeviceValues[T]) Get(device *Device) (T, bool)
- func (values *DeviceValues[T]) Release(dispose func(*Device, T) error) error
- func (values *DeviceValues[T]) Remove(device *Device) (T, bool)
- func (values *DeviceValues[T]) Set(device *Device, value T)
- type Driver
- type EnvironmentEncoding
- type ExternalTextureDescriptor
- type ExternalTextureDriver
- type ExternalTextureFormat
- type ExternalTextureKind
- type ExternalTextureRefreshDriver
- type FrameStatistics
- type GenerationPool
- func (p *GenerationPool[R, V]) Clear()
- func (p *GenerationPool[R, V]) Get(handle Handle[R]) (V, bool)
- func (p *GenerationPool[R, V]) Insert(value V) Handle[R]
- func (p *GenerationPool[R, V]) Len() int
- func (p *GenerationPool[R, V]) Range(yield func(V) bool)
- func (p *GenerationPool[R, V]) Remove(handle Handle[R]) (V, bool)
- type Handle
- type IdleBufferTrimmer
- type Instance2D
- type Instance3D
- type Light3D
- type Light3DKind
- type Material2DShaderDriver
- type Material2DShaderHandle
- type Material2DShaderResource
- type MeshBatch3D
- type MeshBlendMode
- type MeshDeformationData
- type MeshDeformationDescriptor
- type MeshDraw3D
- type MeshDriver
- type MeshGPUDeformationDriver
- type MeshHandle
- type MeshLighting
- type MeshMorphVertex
- type MeshPickingDriver
- type MeshResource
- type MeshShaderDriver
- type MeshShaderHandle
- type MeshShaderResource
- type MeshSkinVertex
- type NativeSurface
- type NativeSurfaceKind
- type Pipeline
- type Rect
- type RenderTarget
- func (target *RenderTarget) Begin(clear RenderTargetClear) error
- func (target *RenderTarget) BeginFor(device *Device, clear RenderTargetClear) error
- func (target *RenderTarget) ColorTexture() (TextureHandle, error)
- func (target *RenderTarget) ColorTextureFor(device *Device) (TextureHandle, error)
- func (target *RenderTarget) DepthTextureFor(device *Device) (TextureHandle, error)
- func (target *RenderTarget) Descriptor() RenderTargetDescriptor
- func (target *RenderTarget) Dispose() error
- func (target *RenderTarget) End() error
- func (target *RenderTarget) Read(region RenderTargetRegion, destination []byte) error
- func (target *RenderTarget) Resize(width, height int) bool
- func (target *RenderTarget) Size() (int, int)
- func (target *RenderTarget) Valid() bool
- type RenderTargetClear
- type RenderTargetColorFormat
- type RenderTargetDescriptor
- type RenderTargetDriver
- type RenderTargetHandle
- type RenderTargetReadbackDriver
- type RenderTargetRegion
- type RenderTargetResource
- type RenderView
- type RenderViewMode
- type RendererInfo
- type ShaderDescriptor
- type ShadowMap3D
- type ShapeBatch
- type ShapeInstance2D
- type ShapeKind
- type SpriteBatch
- type SpriteDraw
- type TextureAddressMode
- type TextureBlock
- type TextureDescriptor
- type TextureFilter
- type TextureFormat
- func (f TextureFormat) Block() TextureBlock
- func (f TextureFormat) ChainSize(width, height, levels int) int
- func (f TextureFormat) Compressed() bool
- func (f TextureFormat) GLCompressedInternalFormat() (int, bool)
- func (f TextureFormat) LevelSize(width, height int) int
- func (f TextureFormat) Name() string
- func (f TextureFormat) SRGB() bool
- func (f TextureFormat) SRGBVariant(srgb bool) TextureFormat
- func (f TextureFormat) TexelBytes() int
- func (f TextureFormat) Valid() bool
- type TextureHandle
- type TextureLevel
- type TextureRegion
- type TextureResource
- type TextureUpdate
- type Vertex3D
Constants ¶
const ( MeshPassLit = iota MeshPassShadowDepth MeshPassOcclusionDepth MeshPassReflectionCapture MeshPassReflectionResolve MeshPassReflectionDepth MeshPassReflectionOcclusion MeshPassFXAA )
Mesh passes reuse the same texture/uniform ABI. SSR resolve aliases shadow records and bindings after capturing direct/indirect illumination.
const MaxMeshLights = 16
MaxMeshLights is the fixed number of extracted lights uploaded to a mesh shader. Keeping the limit stable lets every backend use stack or reused storage and avoids per-frame growth while still allowing mixed light kinds.
const MaxShadowMaps = 16
MaxShadowMaps keeps the complete fragment uniform block within GLES3's minimum 224 vec4 uniforms and Metal's 4 KiB setFragmentBytes limit.
const MeshExtraTextureSlots = MeshSurfaceTextureSlots + 3
const MeshFlagNoReflection = 1 << 22
const MeshSurfaceTextureSlots = 10
const SpriteTextureSlots = 4
SpriteTextureSlots is the built-in sprite pipeline's per-draw texture limit.
Variables ¶
var LCDTextBlend = BlendState{ RGB: Blend{Src: BlendConstantColor, Dst: BlendOneMinusSrcColor}, Alpha: Blend{Src: BlendZero, Dst: BlendOne}, }
LCDTextBlend combines RGB coverage with Constant foreground color in one pass: coverage*foreground + destination*(1-coverage). Surface alpha is kept.
var PremultipliedAlphaBlend = BlendState{ RGB: Blend{Src: BlendOne, Dst: BlendOneMinusSrcAlpha}, Alpha: Blend{Src: BlendOne, Dst: BlendOneMinusSrcAlpha}, }
Functions ¶
func Install ¶
Install replaces the standalone default device. Window-owned devices have independent lifetimes and are never destroyed by this operation.
func MeshSurfaceTextureFlag ¶
func ResizeSurface ¶
func SetSurfaceCornerRadius ¶
func SetSurfaceCornerRadius(radius int)
Types ¶
type Backend ¶
type Backend string
Backend is selected at compile time with an onix_<backend> build tag.
const CompiledBackend Backend = BackendOpenGL
type Blend ¶
type Blend struct {
Src BlendFactor
Dst BlendFactor
}
type BlendFactor ¶
type BlendFactor uint8
const ( BlendZero BlendFactor = iota BlendOne BlendSrcColor BlendOneMinusSrcColor BlendSrcAlpha BlendOneMinusSrcAlpha BlendDstAlpha BlendOneMinusDstAlpha BlendDstColor BlendOneMinusDstColor BlendSrcAlphaSaturate BlendConstantColor BlendOneMinusConstantColor BlendConstantAlpha BlendOneMinusConstantAlpha )
type BlendState ¶
type BufferMemoryStatistics ¶
type BufferMemoryStatistics struct {
InstanceBytes uint64
StagingBytes uint64
ReadbackBytes uint64
NativeScratchBytes uint64
ScratchBytes uint64
}
BufferMemoryStatistics reports reserved transient buffers, including all frames in flight. It excludes textures, resident meshes and driver allocations. NativeScratchBytes reports native buffer, upload and descriptor metadata, retirement queues and CPU snapshots. ScratchBytes is Go memory and is already included in runtime.HeapAlloc.
func CurrentBufferMemoryStatistics ¶
func CurrentBufferMemoryStatistics() BufferMemoryStatistics
CurrentBufferMemoryStatistics must be called on the rendering thread.
func (BufferMemoryStatistics) NativeBytes ¶
func (s BufferMemoryStatistics) NativeBytes() uint64
type Device ¶
Device owns one driver. Activation only selects the immediate rendering context; lifetime belongs to the window or host that created the device.
func ActiveDevice ¶
func ActiveDevice() *Device
func (*Device) BufferMemoryStatistics ¶
func (device *Device) BufferMemoryStatistics() BufferMemoryStatistics
func (*Device) RendererInfo ¶
func (device *Device) RendererInfo() RendererInfo
func (*Device) ResetStatistics ¶
func (device *Device) ResetStatistics()
func (*Device) ResizeSurface ¶
func (*Device) SetSurfaceCornerRadius ¶
func (*Device) Statistics ¶
func (device *Device) Statistics() FrameStatistics
func (*Device) SupportsIdleBufferTrim ¶
func (*Device) TrimIdleBuffers ¶
type DeviceValues ¶
type DeviceValues[T any] struct { // contains filtered or unexported fields }
DeviceValues keeps the common single-device residency inline. Additional devices allocate once on first use; warmed lookups and iteration allocate nothing.
func (*DeviceValues[T]) Clear ¶
func (values *DeviceValues[T]) Clear()
func (*DeviceValues[T]) Each ¶
func (values *DeviceValues[T]) Each(visit func(*Device, T) error) error
func (*DeviceValues[T]) Get ¶
func (values *DeviceValues[T]) Get(device *Device) (T, bool)
func (*DeviceValues[T]) Release ¶
func (values *DeviceValues[T]) Release(dispose func(*Device, T) error) error
func (*DeviceValues[T]) Remove ¶
func (values *DeviceValues[T]) Remove(device *Device) (T, bool)
Remove transfers one device's value to the caller, including values whose device has already been destroyed. Other device residencies remain intact.
func (*DeviceValues[T]) Set ¶
func (values *DeviceValues[T]) Set(device *Device, value T)
type Driver ¶
type Driver interface {
RendererInfo() RendererInfo
BeginFrame(clear Color) error
SetViewport(Rect)
Viewport() Rect
SetBlend(BlendState) error
SetScissor(*Rect)
// CreateTexture consumes pixels before returning; it must copy any bytes
// needed by deferred work. The caller may immediately reuse the slice.
CreateTexture(TextureDescriptor, []byte) (TextureHandle, error)
// UpdateTextures consumes every update's pixels before returning.
UpdateTextures([]TextureUpdate) error
DestroyTexture(TextureHandle) error
DrawSprites(SpriteBatch) error
DrawShapes(ShapeBatch) error
Present() error
ResizeSurface(width, height int) error
SetVSync(enabled bool)
Destroy()
}
Driver is the complete platform rendering boundary. Implementations submit native draw commands; callers never depend on API-specific constants.
func NewOpenGLDriver ¶
func NewOpenGLDriver(surface NativeSurface) (Driver, error)
type EnvironmentEncoding ¶
type EnvironmentEncoding uint8
EnvironmentEncoding describes radiance in the first seven atlas tiles. The eighth tile always stores a linear BRDF LUT.
const ( EnvironmentRGBM EnvironmentEncoding = iota EnvironmentRGBE )
type ExternalTextureDescriptor ¶
type ExternalTextureDescriptor struct {
Handle uint64
Width int
Height int
Modifier uint64
Stride uint32
Offset uint32
Kind ExternalTextureKind
Format ExternalTextureFormat
}
ExternalTextureDescriptor identifies a texture owned by a platform media pipeline. Handle is opaque to the render package and is interpreted only by a driver implementing ExternalTextureDriver.
func (ExternalTextureDescriptor) Validate ¶
func (d ExternalTextureDescriptor) Validate() error
type ExternalTextureDriver ¶
type ExternalTextureDriver interface {
CreateExternalTexture(ExternalTextureDescriptor) (TextureHandle, error)
}
ExternalTextureDriver is optional. Existing renderers continue to use the CPU upload path unless they explicitly support importing platform surfaces.
type ExternalTextureFormat ¶
type ExternalTextureFormat uint8
const ( ExternalTextureBGRA8 ExternalTextureFormat = iota + 1 ExternalTextureRGBA8 )
type ExternalTextureKind ¶
type ExternalTextureKind uint8
const ( ExternalTextureD3D11 ExternalTextureKind = iota + 1 ExternalTextureDMABuf ExternalTextureVulkan ExternalTextureMetal )
type ExternalTextureRefreshDriver ¶
type ExternalTextureRefreshDriver interface {
RefreshExternalTexture(TextureHandle) error
}
ExternalTextureRefreshDriver marks an imported texture as having new producer content. Renderers use this hook to attach cross-API synchronization only to frames that actually consume a new surface.
type FrameStatistics ¶
type FrameStatistics struct {
SurfaceWidth uint64
SurfaceHeight uint64
DrawCalls uint64
Sprites uint64
Shapes uint64
Meshes uint64
Vertices uint64
Triangles uint64
SpriteDrawCalls uint64
ShapeDrawCalls uint64
MeshDrawCalls uint64
BufferUploadBytes uint64
DynamicMeshDrawCalls uint64
DynamicMeshVertices uint64
DynamicMeshIndices uint64
DynamicMeshUploadBytes uint64
TextureUploads uint64
TextureUploadBytes uint64
}
FrameStatistics describes the work submitted to the GPU in the current frame. It reports submission and upload counts, not fragment count or GPU execution time; use a platform GPU capture for those measurements.
func Statistics ¶
func Statistics() FrameStatistics
Statistics returns a snapshot of the draw work submitted so far this frame.
type GenerationPool ¶
type GenerationPool[R, V any] struct { // contains filtered or unexported fields }
func (*GenerationPool[R, V]) Clear ¶
func (p *GenerationPool[R, V]) Clear()
func (*GenerationPool[R, V]) Get ¶
func (p *GenerationPool[R, V]) Get(handle Handle[R]) (V, bool)
func (*GenerationPool[R, V]) Insert ¶
func (p *GenerationPool[R, V]) Insert(value V) Handle[R]
func (*GenerationPool[R, V]) Len ¶
func (p *GenerationPool[R, V]) Len() int
func (*GenerationPool[R, V]) Range ¶
func (p *GenerationPool[R, V]) Range(yield func(V) bool)
func (*GenerationPool[R, V]) Remove ¶
func (p *GenerationPool[R, V]) Remove(handle Handle[R]) (V, bool)
type Handle ¶
type Handle[T any] struct { // contains filtered or unexported fields }
Handle is a typed GPU resource reference.
func (Handle[T]) Generation ¶
type IdleBufferTrimmer ¶
type IdleBufferTrimmer interface{ TrimIdleBuffers() error }
IdleBufferTrimmer releases transient storage after submitted work completes. App calls it on the rendering thread, outside any active frame.
type Instance2D ¶
type Instance3D ¶
type Instance3D struct {
Model [16]float32
BaseColor [4]float32
EmissiveMetallic [4]float32 // emissive RGB after strength, metallic
Material [4]float32 // roughness, IOR, alpha cutoff, flags
UVTransform [4]float32
Custom [4][4]float32
}
func (Instance3D) PickingID ¶
func (instance Instance3D) PickingID() uint32
func (*Instance3D) SetPickingID ¶
func (instance *Instance3D) SetPickingID(id uint32)
SetPickingID stores an exact uint32 bit pattern in the instance lane used by the dedicated picking shaders. Picking batches are copies, so material custom data in the simulation world is never modified.
type Light3D ¶
type Light3D struct {
Kind Light3DKind
Right [4]float32
Up [4]float32
PositionDirection [4]float32
Direction [4]float32
Color [4]float32
Params [4]float32
}
Light3D is a renderer-independent extracted light. PositionDirection uses xyz as a position for local lights and as a direction for directional lights. Color.rgb is linear; Color.w is the source radius. Params stores range, candela/nits (lux for box), and cone cosines. Right/Up carry orthonormal axes and shape dimensions in w.
type Light3DKind ¶
type Light3DKind uint32
const ( Light3DAmbient Light3DKind = iota Light3DDirectional Light3DPoint Light3DSpot Light3DPyramid Light3DBox Light3DRectangle Light3DDisc Light3DTube )
type Material2DShaderDriver ¶
type Material2DShaderDriver interface {
CreateMaterial2DShader(ShaderDescriptor) (Material2DShaderHandle, error)
DestroyMaterial2DShader(Material2DShaderHandle) error
}
Material2DShaderDriver is implemented by sprite renderers that can compile user-provided Material2D pipelines.
type Material2DShaderHandle ¶
type Material2DShaderHandle = Handle[Material2DShaderResource]
type Material2DShaderResource ¶
type Material2DShaderResource struct{}
type MeshBatch3D ¶
type MeshBatch3D struct {
Lights []Light3D
Vertices []Vertex3D
Indices []uint32
Instances []Instance3D
Draws []MeshDraw3D
Deformations []MeshDeformationData
Lighting MeshLighting
ViewProjection [16]float32
CameraPosition [4]float32
AmbientLight [4]float32
LightDirection [4]float32
DirectionalLight [4]float32
}
type MeshBlendMode ¶
type MeshBlendMode uint32
const ( MeshBlendNormal MeshBlendMode = iota MeshBlendAdditive MeshBlendMultiply MeshBlendScreen )
type MeshDeformationData ¶
type MeshDeformationData struct {
JointMatrices []mgl32.Mat4
MorphWeights []float32
Mesh MeshHandle
}
MeshDeformationData borrows only the animated parameters for this submission. Static skin and morph streams reside in Mesh until DestroyMesh.
type MeshDeformationDescriptor ¶
type MeshDeformationDescriptor struct {
Skin []MeshSkinVertex
MorphTargets []MeshMorphVertex
VertexCount uint32
TargetCount uint32
}
MeshDeformationDescriptor is uploaded once and owned by the mesh resource. SetMeshDeformation copies its slices; changing the streams requires a new mesh.
type MeshDraw3D ¶
type MeshDraw3D struct {
// SurfaceTextures follow MaterialSurface.Textures order.
SurfaceTextures [MeshSurfaceTextureSlots]TextureHandle
Mesh MeshHandle
Shader MeshShaderHandle
Texture TextureHandle
NormalTexture TextureHandle
// MetallicRoughnessTexture stores glTF's occlusion-independent
// metallic (B) and roughness (G) channels. A zero handle makes the
// renderer use the scalar material factors.
MetallicRoughnessTexture TextureHandle
FirstIndex uint32
IndexCount uint32
BaseVertex int32
FirstInstance uint32
InstanceCount uint32
AlphaMode uint32
BlendMode MeshBlendMode
// DeformationIndex is one-based into MeshBatch3D.Deformations. Zero
// means that the draw uses its original vertex attributes.
DeformationIndex uint32
}
func (MeshDraw3D) ExtraTextures ¶
func (draw MeshDraw3D) ExtraTextures(lighting *MeshLighting) [MeshExtraTextureSlots]TextureHandle
type MeshDriver ¶
type MeshDriver interface {
CreateMesh([]Vertex3D, []uint32) (MeshHandle, error)
DestroyMesh(MeshHandle) error
DrawMeshes(MeshBatch3D) error
}
MeshDriver is implemented by drivers that expose Onix's indexed 3D mesh pipeline. It is separate from Driver so headless and specialized 2D drivers do not need meaningless 3D methods.
type MeshGPUDeformationDriver ¶
type MeshGPUDeformationDriver interface {
SetMeshDeformation(MeshHandle, MeshDeformationDescriptor) error
DrawMeshesDeformed(MeshBatch3D) error
}
MeshGPUDeformationDriver is implemented by renderers that evaluate skin and morph data in GPU buffers. Drivers that do not implement it use the CPU fallback assembled by scene.ExtractRender3DSystem.
type MeshHandle ¶
type MeshHandle = Handle[MeshResource]
type MeshLighting ¶
type MeshLighting struct {
FogColor [3]float32 // linear radiance in nits
FogParams [4]float32 // start, end, density, mode (0 disabled, 1 linear, 2 exp2)
ToneMapping float32 // 0 Reinhard, 1 ACES filmic fit
OcclusionInverseProjection [16]float32
OcclusionParams [4]float32 // world radius, world bias, strength, sample count
OcclusionTexture TextureHandle
Shadows [MaxShadowMaps]ShadowMap3D
LightShadows [MaxMeshLights][4]float32 // one-based first map, map count, cascade blend; W carries camera color/fog and environment encoding on upload
CameraForward [4]float32 // world direction used to select directional cascades; W is replaced by SSAO sample count on upload
Environment [4]float32 // intensity, rotation, atlas inverse width, inverse tile height
EnvironmentEncoding EnvironmentEncoding
Params [4]float32 // exposure (0 means 1), MeshPass*, SSAO strength on upload, backend winding flip
EnvironmentTexture TextureHandle
ShadowTexture TextureHandle
}
MeshLighting is shared by all backends. Shadow and occlusion passes sample the depth attachment directly.
type MeshMorphVertex ¶
MeshMorphVertex stores one morph target delta for one vertex.
type MeshPickingDriver ¶
type MeshPickingDriver interface {
DrawMeshPicking(MeshBatch3D) error
}
MeshPickingDriver draws mesh instances as uint32 entity IDs into the active R32Uint render target.
type MeshResource ¶
type MeshResource struct{}
type MeshShaderDriver ¶
type MeshShaderDriver interface {
CreateMeshShader(ShaderDescriptor) (MeshShaderHandle, error)
DestroyMeshShader(MeshShaderHandle) error
}
MeshShaderDriver is implemented by mesh renderers that can compile and own user-provided mesh pipelines.
type MeshShaderHandle ¶
type MeshShaderHandle = Handle[MeshShaderResource]
type MeshShaderResource ¶
type MeshShaderResource struct{}
type MeshSkinVertex ¶
MeshSkinVertex stores the four influences used by GPU linear-blend skinning. The layout is intentionally renderer-independent so backends can pack it into a storage buffer without importing graphics types.
type NativeSurface ¶
type NativeSurfaceKind ¶
type NativeSurfaceKind int
const ( NativeSurfaceXlib NativeSurfaceKind = iota + 1 NativeSurfaceWayland NativeSurfaceAndroid NativeSurfaceWin32 NativeSurfaceDRM NativeSurfaceMetal )
type RenderTarget ¶
type RenderTarget struct {
// contains filtered or unexported fields
}
RenderTarget owns the offscreen attachments in its descriptor. Resize is deferred until the target is next used.
func NewRenderTarget ¶
func NewRenderTarget(descriptor RenderTargetDescriptor) (*RenderTarget, error)
func (*RenderTarget) Begin ¶
func (target *RenderTarget) Begin(clear RenderTargetClear) error
func (*RenderTarget) BeginFor ¶
func (target *RenderTarget) BeginFor(device *Device, clear RenderTargetClear) error
func (*RenderTarget) ColorTexture ¶
func (target *RenderTarget) ColorTexture() (TextureHandle, error)
func (*RenderTarget) ColorTextureFor ¶
func (target *RenderTarget) ColorTextureFor(device *Device) (TextureHandle, error)
func (*RenderTarget) DepthTextureFor ¶ added in v0.1.8
func (target *RenderTarget) DepthTextureFor(device *Device) (TextureHandle, error)
DepthTextureFor returns the sampled image owned by a depth-only target.
func (*RenderTarget) Descriptor ¶
func (target *RenderTarget) Descriptor() RenderTargetDescriptor
func (*RenderTarget) Dispose ¶
func (target *RenderTarget) Dispose() error
func (*RenderTarget) End ¶
func (target *RenderTarget) End() error
func (*RenderTarget) Read ¶
func (target *RenderTarget) Read(region RenderTargetRegion, destination []byte) error
func (*RenderTarget) Resize ¶
func (target *RenderTarget) Resize(width, height int) bool
func (*RenderTarget) Size ¶
func (target *RenderTarget) Size() (int, int)
func (*RenderTarget) Valid ¶
func (target *RenderTarget) Valid() bool
Valid reports whether the target can be realized, without accessing a device.
type RenderTargetClear ¶
type RenderTargetColorFormat ¶
type RenderTargetColorFormat uint8
const ( RenderTargetRGBA8 RenderTargetColorFormat = iota RenderTargetUint32 RenderTargetR8 // RenderTargetDepth exposes the depth attachment for sampling and allocates no color image. RenderTargetDepth )
func (RenderTargetColorFormat) TexelBytes ¶
func (format RenderTargetColorFormat) TexelBytes() int
TexelBytes returns the byte size used by color attachment readback.
type RenderTargetDescriptor ¶
type RenderTargetDescriptor struct {
Width int
Height int
ColorFormat RenderTargetColorFormat
Depth bool
// SingleSample skips window MSAA for targets used for compositing and filtering.
SingleSample bool
}
func (RenderTargetDescriptor) Validate ¶
func (descriptor RenderTargetDescriptor) Validate() error
type RenderTargetDriver ¶
type RenderTargetDriver interface {
CreateRenderTarget(RenderTargetDescriptor) (RenderTargetHandle, TextureHandle, error)
ResizeRenderTarget(RenderTargetHandle, RenderTargetDescriptor) (TextureHandle, error)
DestroyRenderTarget(RenderTargetHandle) error
BeginRenderTarget(RenderTargetHandle, RenderTargetClear) error
EndRenderTarget() error
}
type RenderTargetHandle ¶
type RenderTargetHandle = Handle[RenderTargetResource]
type RenderTargetReadbackDriver ¶
type RenderTargetReadbackDriver interface {
ReadRenderTarget(RenderTargetHandle, RenderTargetRegion, []byte) error
}
type RenderTargetRegion ¶
type RenderTargetResource ¶
type RenderTargetResource struct{}
type RenderView ¶
type RenderView[T any] struct { Camera T Target *RenderTarget Viewport Rect Clear RenderTargetClear Order int Mode RenderViewMode Enabled bool }
RenderView binds typed camera data to an optional output target. The camera payload remains owned by the caller, so render does not depend on ECS types.
func NewRenderView ¶
func NewRenderView[T any](camera T) RenderView[T]
type RenderViewMode ¶
type RenderViewMode uint8
const ( RenderViewLit RenderViewMode = iota RenderViewUnlit RenderViewWireframe RenderViewPicking )
type RendererInfo ¶
type RendererInfo struct {
Backend string
Device string
// RenderTargetBottomLeft reports whether sampled color attachments use a
// bottom-left origin. RenderTarget.Read always uses a top-left origin.
RenderTargetBottomLeft bool
}
RendererInfo identifies the active graphics API and physical device.
func CurrentRendererInfo ¶
func CurrentRendererInfo() RendererInfo
CurrentRendererInfo returns metadata reported by the active render driver.
type ShaderDescriptor ¶
type ShaderDescriptor struct {
MetalSource string
WebGL2VertexSource string
WebGL2FragmentSource string
WebGPUVertexSource string
WebGPUFragmentSource string
VulkanVertexSPIRV []byte
VulkanFragmentSPIRV []byte
DirectXVertexHLSL []byte
DirectXFragmentHLSL []byte
WebGL2Generated bool
}
ShaderDescriptor contains the native shader representation for each renderer. A descriptor may target only the platforms shipped by the game; an omitted vertex or fragment stage inherits the pipeline's built-in stage.
func (ShaderDescriptor) Validate ¶
func (d ShaderDescriptor) Validate() error
type ShadowMap3D ¶
type ShapeBatch ¶
type ShapeBatch struct {
Instances []ShapeInstance2D
Projection [16]float32
}
type ShapeInstance2D ¶
type SpriteBatch ¶
type SpriteBatch struct {
Instances []Instance2D
Draws []SpriteDraw
Projection [16]float32
}
type SpriteDraw ¶
type SpriteDraw struct {
Shader Material2DShaderHandle
Texture TextureHandle
AdditionalTextures [SpriteTextureSlots - 1]TextureHandle
FirstInstance uint32
InstanceCount uint32
}
func (SpriteDraw) TextureAt ¶
func (d SpriteDraw) TextureAt(slot int) TextureHandle
TextureAt fills unused bindings with the primary texture. Custom shaders use only Texture and retain their single-texture sampling contract.
type TextureAddressMode ¶
type TextureAddressMode uint8
TextureAddressMode controls sampling outside normalized texture coordinates.
const ( TextureAddressClamp TextureAddressMode = iota TextureAddressRepeat TextureAddressMirror )
func (TextureAddressMode) Valid ¶
func (m TextureAddressMode) Valid() bool
type TextureBlock ¶
TextureBlock is the texel granularity of a format. Uncompressed formats use a 1x1 block; block-compressed formats use 4x4.
type TextureDescriptor ¶
type TextureDescriptor struct {
Width int
Height int
// Levels is the number of mip levels described by the pixel payload.
// Zero and one both mean a single level. Compressed formats ship a
// prebuilt chain because the GPU cannot generate mips for block data.
Levels int
WrapU, WrapV TextureAddressMode
Filter TextureFilter
Format TextureFormat
}
func (TextureDescriptor) Level ¶
func (d TextureDescriptor) Level(level int) TextureLevel
Level reports where one mip level lives inside the payload. Level 0 is the base level, which starts at offset zero; negative levels clamp to it.
Sequential uploads use MipChain to avoid recalculating preceding levels.
func (TextureDescriptor) MipChain ¶
func (d TextureDescriptor) MipChain(yield func(int, TextureLevel) bool)
MipChain walks the payload once, carrying dimensions and the byte offset forward instead of recomputing all preceding levels for every upload.
func (TextureDescriptor) MipLevels ¶
func (d TextureDescriptor) MipLevels() int
MipLevels reports the mip depth described by the descriptor.
func (TextureDescriptor) Validate ¶
func (d TextureDescriptor) Validate(pixels []byte) error
type TextureFilter ¶
type TextureFilter uint8
const ( TextureFilterLinear TextureFilter = iota TextureFilterLinearMipmapLinear )
type TextureFormat ¶
type TextureFormat uint8
TextureFormat identifies the texel layout used by a sampled texture. RGBA8 remains the zero value so existing descriptors keep their behavior.
const ( TextureFormatRGBA8 TextureFormat = iota TextureFormatR8 // TextureFormatSRGBA8 decodes RGB from sRGB when sampled; alpha stays linear. TextureFormatSRGBA8 // Block-compressed formats encode independent 4x4 texel blocks, so a // texture smaller than the block size still occupies a whole block. TextureFormatBC1 // RGB, 4 bits per texel TextureFormatBC1SRGB // BC1 sampled as sRGB TextureFormatBC3 // RGB with interpolated alpha, 8 bits per texel TextureFormatBC3SRGB // BC3 sampled as sRGB TextureFormatBC4 // single channel, 4 bits per texel TextureFormatBC5 // two channel, 8 bits per texel TextureFormatBC7 // RGBA, 8 bits per texel TextureFormatBC7SRGB // BC7 sampled as sRGB TextureFormatASTC4x4 // RGBA, 8 bits per texel TextureFormatASTC4x4SRGB // ASTC 4x4 sampled as sRGB )
func (TextureFormat) Block ¶
func (f TextureFormat) Block() TextureBlock
Block reports the texel granularity and encoded size of one block.
func (TextureFormat) ChainSize ¶
func (f TextureFormat) ChainSize(width, height, levels int) int
ChainSize reports the encoded byte size of a full or partial mip chain. Levels above the natural depth are clamped.
func (TextureFormat) Compressed ¶
func (f TextureFormat) Compressed() bool
Compressed reports whether the format stores 4x4 blocks. Compressed textures cannot be updated in place, because a partial region does not cover whole blocks.
func (TextureFormat) GLCompressedInternalFormat ¶
func (f TextureFormat) GLCompressedInternalFormat() (int, bool)
GLCompressedInternalFormat maps a compressed format to the GL internal format constant shared by OpenGL ES and WebGL2. The second result is false for uncompressed formats, which take the texel upload path instead.
func (TextureFormat) LevelSize ¶
func (f TextureFormat) LevelSize(width, height int) int
LevelSize reports the encoded byte size of one mip level. Dimensions that are not a whole number of blocks round up, matching every native API.
func (TextureFormat) Name ¶
func (f TextureFormat) Name() string
Name reports a stable identifier used by tooling and error messages.
func (TextureFormat) SRGB ¶
func (f TextureFormat) SRGB() bool
SRGB reports whether sampling decodes RGB from sRGB. Alpha stays linear.
func (TextureFormat) SRGBVariant ¶
func (f TextureFormat) SRGBVariant(srgb bool) TextureFormat
SRGBVariant returns the format that samples the same blocks with the requested colour interpretation.
A block-compressed format and its sRGB variant store identical blocks; only the internal format chosen at upload differs, which is what makes the device decode gamma. A packed payload therefore does not have to be re-encoded to serve a sampler that wants the other interpretation. Formats without a variant, and R8 which carries data rather than colour, are returned as-is.
func (TextureFormat) TexelBytes ¶
func (f TextureFormat) TexelBytes() int
TexelBytes reports the encoded size of one texel. Compressed formats report 0 because their texels are not independently addressable; use LevelSize or ChainSize for those.
func (TextureFormat) Valid ¶
func (f TextureFormat) Valid() bool
type TextureHandle ¶
type TextureHandle = Handle[TextureResource]
type TextureLevel ¶
type TextureLevel struct {
Width int
Height int
// Offset is the byte offset of the level inside the payload.
Offset int
// Bytes is the encoded size of the level. Block-compressed levels round
// their dimensions up to whole blocks, so a 1x1 level still occupies one
// full block.
Bytes int
}
TextureLevel locates one mip level inside the payload a descriptor describes.
type TextureResource ¶
type TextureResource struct{}
type TextureUpdate ¶
type TextureUpdate struct {
Pixels []byte
Region TextureRegion
Texture TextureHandle
}
Source Files
¶
- backend.go
- backend_opengl.go
- bool_native.go
- buffer_memory.go
- buffer_pool.go
- buffer_retention.go
- device.go
- device_values.go
- frame_cache.go
- generation_pool.go
- handle.go
- mesh_deformation.go
- mesh_lights.go
- mesh_variants.go
- native_draw.go
- native_resource.go
- native_scalar.go
- native_texture_upload.go
- opengl_context.go
- opengles.go
- sprite_instances.go
- sprite_shaders.go
- statistics.go
- surface.go
- target.go
- texture_format.go
- texture_upload.go
- view.go
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
dxbcgen
command
Command dxbcgen compiles generated HLSL into builtin DirectX 11 bytecode.
|
Command dxbcgen compiles generated HLSL into builtin DirectX 11 bytecode. |
|
hlslgen
command
Command hlslgen regenerates DirectX builtins from the shared WGSL sources.
|
Command hlslgen regenerates DirectX builtins from the shared WGSL sources. |