gles

package
v0.34.8 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT Imports: 22 Imported by: 1

Documentation

Overview

Package gles implements the HAL backend for OpenGL ES 3.0 / OpenGL 3.3+.

This backend is Pure Go, without CGO: syscall on Windows, goffi on Linux.

Platform Support

Supported:

  • Windows (WGL) - via hal/gles/wgl package
  • Linux (EGL: X11, Wayland, surfaceless) - via hal/gles/egl package

Planned:

  • Android (EGL)
  • WebGL (via wasm)

Architecture

The backend is organized into subpackages:

hal/gles/
├── gl/       - OpenGL function bindings
├── wgl/      - Windows GL context management
└── egl/      - EGL display and context management (Linux)

Usage

Import this package to register the OpenGL backend:

import _ "github.com/gogpu/wgpu/hal/gles"

The backend is then available via hal.GetBackend(gputypes.BackendGL).

OpenGL Version Requirements

Minimum requirements:

  • OpenGL 3.3 Core Profile (desktop)
  • OpenGL ES 3.0 (mobile/embedded)

The backend queries actual capabilities at runtime and adjusts feature availability accordingly.

Limitations

Compared to Vulkan/Metal/DX12:

  • No async compute (compute runs on graphics queue)
  • Limited bindless resource support
  • Single command queue
  • Synchronous texture uploads

Command Recording

This backend uses a command recording pattern similar to wgpu-hal. Commands are recorded during render/compute pass encoding and executed during Queue.Submit. This allows for:

  • State tracking and optimization
  • Better error handling
  • Potential future multithreading

Index

Constants

This section is empty.

Variables

View Source
var ErrContextReleased = hal.ErrContextReleased

ErrContextReleased is returned when an EGL context is used after the last Surface and Device built on it were released: the context, and every GL object in it, is gone. A cached Adapter of a closed window returns it from Open; request an adapter with the new surface instead. It is hal.ErrContextReleased (wgpu.ErrContextReleased in the public package), which wraps hal.ErrDeviceLost.

Functions

func GLSLVersionToNaga added in v0.29.13

func GLSLVersionToNaga(glslVersion int, isES bool) glsl.Version

GLSLVersionToNaga converts an integer GLSL version (e.g., 410, 430, 300) and ES flag into a naga glsl.Version struct for shader compilation.

The integer encoding matches GL_SHADING_LANGUAGE_VERSION parsing: "4.30" -> 430, "3.30" -> 330, "3.00 ES" -> 300 with isES=true. In the Version struct, Major is the hundreds digit and Minor is the tens+units. For example, 430 -> {Major: 4, Minor: 30}, 300 -> {Major: 3, Minor: 0}.

If glslVersion is 0 (detection failed), returns glsl.Version330 (desktop) or glsl.VersionES300 (ES) as safe minimums matching Rust naga defaults.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter implements hal.Adapter for OpenGL on Linux. Holds its *AdapterContext weakly (ADR-077): an adapter is often kept by an app without being released, and a strong reference would keep the context, and the EGLDisplay under it, alive past the native display the app closes. Open takes the Device's own reference and fails once the context is gone.

func (*Adapter) Destroy

func (a *Adapter) Destroy()

Destroy releases the adapter. It holds no reference to its context.

func (*Adapter) Open

Open creates a logical device with the requested features and limits. The Device holds a reference to the adapter's context until Destroy, and the Queue borrows it. Once every surface and device of the context is gone, Open returns ErrContextReleased.

func (*Adapter) QualifySurface

func (a *Adapter) QualifySurface(surface hal.Surface) (hal.Adapter, error)

QualifySurface returns a request-local adapter for surface, bound to the context the surface uses. Core calls it for the cached adapter when a new surface asks for an adapter (core/instance.go surfaceAdapterQualifier), as for Vulkan. GLES enumerates once per instance, with the first surface; a window closed and reopened in the same Instance gets a new context, and this gives it an adapter that opens on it. The returned adapter holds the context weakly, like every GLES adapter.

func (*Adapter) SurfaceCapabilities

func (a *Adapter) SurfaceCapabilities(_ hal.Surface) *hal.SurfaceCapabilities

SurfaceCapabilities returns surface capabilities, or nil when the adapter's context is gone: no Device can be opened to present with.

func (*Adapter) TextureFormatCapabilities

func (a *Adapter) TextureFormatCapabilities(format gputypes.TextureFormat) hal.TextureFormatCapabilities

TextureFormatCapabilities returns capabilities for a texture format. Uses probed GL extension and MSAA information for accurate per-format detection.

type AdapterCapabilities added in v0.28.4

type AdapterCapabilities struct {
	// Vendor/renderer/version strings as returned by GL.
	Vendor   string
	Renderer string
	Version  string

	// Parsed GL version numbers (e.g., [4, 6] for OpenGL 4.6).
	GLMajor int
	GLMinor int

	// True if this is an OpenGL ES context (as opposed to desktop GL).
	IsES bool

	// GLSL version number (e.g., 460 for GLSL 4.60).
	GLSLVersion int

	// Set of supported GL extensions.
	Extensions map[string]bool

	// Maximum MSAA sample count (from GL_MAX_SAMPLES).
	MaxMSAASamples int32

	// Detected features.
	Features gputypes.Features

	// Queried limits.
	Limits gputypes.Limits

	// Downlevel capability flags.
	DownlevelFlags gputypes.DownlevelFlags

	// Inferred device type.
	DeviceType gputypes.DeviceType

	// Inferred vendor ID.
	VendorID uint32

	// FullyFeaturedInstancing is Rust wgpu-hal's FULLY_FEATURED_INSTANCING:
	// desktop GL 4.2+ with GL_ARB_shader_draw_parameters and the base-instance
	// draws loaded. Draws then pass the first instance to GL
	// (glDraw*BaseInstance, and the baseInstance field of an indirect record),
	// and shaders read gl_BaseInstanceARB. Without it the first instance is
	// emulated: the naga_vs_first_instance uniform and instance-stepped
	// vertex buffer offsets.
	FullyFeaturedInstancing bool
}

AdapterCapabilities holds parsed adapter information queried from GL at adapter enumeration time. Populated by queryAdapterCapabilities and consumed by GetAdapterInfo in the platform-specific resource files.

type AdapterContext added in v0.34.4

type AdapterContext struct {
	// contains filtered or unexported fields
}

AdapterContext wraps an EGL/GL context with mutex-protected MakeCurrent switching, and counts the objects that keep the context alive (ADR-077 B).

A context lives as long as its strong holders: the Surface (or the Instance, for its own context) that created it, every Surface that shares it, and every Device opened on it (the Queue borrows the Device's). Adapters and the Instance's table of surface-created contexts hold it weakly and take a temporary reference to use it. The last Release destroys the EGLContext while the native display under it is still open, which the documented surface order guarantees; tying it to the Instance instead let eglTerminate run after the app had closed its display (#379).

Two locks with separate jobs:

  • mu is held while the context is current on a thread: Lock or LockForSurface until Unlock (Rust wgpu-hal AdapterContext::lock).
  • refs has its own lock for the count and the dead mark, never held across a GL call, so bookkeeping never waits behind GL work.

gl and eglCtx are set at construction and never change; destruction only marks the context dead. GL() and EGL() therefore take no lock, which code under Lock relies on (CreateRenderPipeline → compileFragmentShader).

func NewAdapterContext added in v0.34.4

func NewAdapterContext(eglCtx *egl.Context, glCtx *gl.Context) *AdapterContext

NewAdapterContext wraps an already-created EGL context and GL function table. The caller holds the first reference and gives it up with Release.

func (*AdapterContext) Acquire

func (c *AdapterContext) Acquire() bool

Acquire takes one more reference to the context and reports whether it did. It fails once the last reference was released: the context never comes back.

func (*AdapterContext) Alive

func (c *AdapterContext) Alive() bool

Alive reports whether a reference to the context is still held.

func (*AdapterContext) EGL added in v0.34.4

func (c *AdapterContext) EGL() *egl.Context

EGL returns the underlying EGL context wrapper. It takes no lock.

func (*AdapterContext) GL added in v0.34.4

func (c *AdapterContext) GL() *gl.Context

GL returns the GL function table. It takes no lock; GL calls on the returned context require Lock.

func (*AdapterContext) Lock added in v0.34.4

func (c *AdapterContext) Lock() (*gl.Context, error)

Lock acquires the mutex, pins the goroutine to the current OS thread, and makes the GL context current on the pbuffer / surfaceless draw surface.

On a released context it returns ErrContextReleased with nothing held: the caller must not call Unlock. Every caller follows one convention:

glCtx, err := c.Lock()
if err != nil {
	return …
}
defer c.Unlock()

Mirrors Windows AdapterContext.Lock() (hidden DC) and Rust AdapterContext::lock().

func (*AdapterContext) LockForSurface added in v0.34.4

func (c *AdapterContext) LockForSurface(surf egl.EGLSurface) (*gl.Context, error)

LockForSurface acquires the mutex, pins the goroutine to the current OS thread, and makes the GL context current on the given window EGLSurface. Its error convention is Lock's.

Mirrors Windows AdapterContext.LockForDC() and Rust lock_with_dc / egl present path.

func (*AdapterContext) Release

func (c *AdapterContext) Release()

Release gives up one reference. The last one destroys the context:

  1. the dead mark is set under the refs lock, in the same critical section as the decrement, so no Acquire or Lock succeeds after it;
  2. mu is taken, which waits out a holder that made the context current before the mark;
  3. the EGLContext is destroyed and its display released on a pinned OS thread, under mu but outside the refs lock. A Lock that comes in meanwhile waits, then fails on the dead mark. mu is only ever taken before the display registry's lock, never after it, so this cannot deadlock.

Release must not be called while the same goroutine holds Lock.

func (*AdapterContext) RobustAccess

func (c *AdapterContext) RobustAccess() bool

RobustAccess reports whether the EGL context was created with robust buffer access.

func (*AdapterContext) Unlock added in v0.34.4

func (c *AdapterContext) Unlock()

Unlock unmakes the GL context current, unpins the goroutine from the OS thread, and releases the mutex. Only after a Lock that returned no error.

Guards against double-unmake: only calls eglMakeCurrent(NO_SURFACE, NO_CONTEXT) if a context is actually current on this thread. Matches Windows Unlock() and Rust WglContext::unmake_current().

type AttachColorCommand added in v0.31.8

type AttachColorCommand struct {
	// contains filtered or unexported fields
}

AttachColorCommand attaches a color texture to a specific FBO attachment point. Used for MRT (Multiple Render Targets) to bind attachments 1..N. Attachment 0 is bound by EnsureOffscreenFBOCommand. Matches Rust wgpu-hal GLES BindAttachment for color targets (command.rs:580-582).

func (*AttachColorCommand) Execute added in v0.31.8

func (c *AttachColorCommand) Execute(ctx *gl.Context)

type AttachDepthStencilCommand added in v0.16.0

type AttachDepthStencilCommand struct {
	// contains filtered or unexported fields
}

AttachDepthStencilCommand attaches a depth/stencil texture to the currently bound FBO (the one associated with the color texture). This must be recorded after EnsureOffscreenFBOCommand so the FBO is already bound.

The view's mip level and layer are attached (Rust wgpu-hal gles/queue.rs set_attachment). Attaching level 0 through glFramebufferTexture2D, which has no layer and rejects a 2D array target, left a depth view of another level or of an array layer unattached.

func (*AttachDepthStencilCommand) Execute added in v0.16.0

func (c *AttachDepthStencilCommand) Execute(ctx *gl.Context)

type AttachDepthStencilToFBOCommand added in v0.30.26

type AttachDepthStencilToFBOCommand struct {
	// contains filtered or unexported fields
}

AttachDepthStencilToFBOCommand attaches a depth/stencil texture to the currently bound FBO. Unlike AttachDepthStencilCommand, this does not reference a color texture — it operates on whatever FBO is currently bound (typically the surface swapchain FBO).

The attachment point is chosen by texture format (Rust wgpu-hal command.rs:577-580):

  • depth-only → GL_DEPTH_ATTACHMENT
  • stencil-only → GL_STENCIL_ATTACHMENT
  • depth+stencil → GL_DEPTH_STENCIL_ATTACHMENT

Like AttachDepthStencilCommand it attaches the view's mip level and layer.

func (*AttachDepthStencilToFBOCommand) Execute added in v0.30.26

func (c *AttachDepthStencilToFBOCommand) Execute(ctx *gl.Context)

type Backend

type Backend struct{}

Backend implements hal.Backend for OpenGL ES / OpenGL 3.3+ on Linux.

func NewBackend added in v0.32.0

func NewBackend() Backend

NewBackend returns a GLES backend instance.

func (Backend) CreateInstance

func (Backend) CreateInstance(desc *hal.InstanceDescriptor) (hal.Instance, error)

CreateInstance creates a new OpenGL instance with an optional EGL context. Attempts to create an EGL context at instance level (Rust wgpu-hal egl.rs:846 parity) for adapter enumeration without a surface. Uses surfaceless/pbuffer context — same role as Windows hidden 1×1 HWND (v0.28.6).

On Wayland, this may fail (EGL needs wl_display*) — that's OK, CreateSurface provides the proper context later. On X11/headless, this succeeds.

With desc.Display set, the context is built on that display at init, Wayland included (Rust wgpu-hal egl.rs Instance::init with InstanceDescriptor.display). If that fails, the backend is absent for this Instance, as in Rust: the error is returned and logged.

func (Backend) Variant

func (Backend) Variant() gputypes.Backend

Variant returns the backend type identifier.

type BindDepthStencilFBOCommand

type BindDepthStencilFBOCommand struct {
	// contains filtered or unexported fields
}

BindDepthStencilFBOCommand binds the framebuffer of a pass without color attachments: the depth/stencil texture's FBO, created lazily, with one mip level and layer of the texture at its depth/stencil attachment point. The FBO is shared with the texture's readbacks (CopyTextureToBufferCommand bindSourceFBO), so the level and layer are attached for every pass.

func (*BindDepthStencilFBOCommand) Execute

func (c *BindDepthStencilFBOCommand) Execute(ctx *gl.Context)

type BindFramebufferCommand added in v0.16.0

type BindFramebufferCommand struct {
	// contains filtered or unexported fields
}

BindFramebufferCommand binds a framebuffer object.

func (*BindFramebufferCommand) Execute added in v0.16.0

func (c *BindFramebufferCommand) Execute(ctx *gl.Context)

type BindGroup

type BindGroup struct {
	// contains filtered or unexported fields
}

BindGroup implements hal.BindGroup for OpenGL.

func (*BindGroup) Destroy

func (g *BindGroup) Destroy()

Destroy is a no-op for bind groups.

type BindGroupDescriptor

type BindGroupDescriptor = hal.BindGroupDescriptor

Type aliases for hal descriptors

type BindGroupLayout

type BindGroupLayout struct {
	// contains filtered or unexported fields
}

BindGroupLayout implements hal.BindGroupLayout for OpenGL.

func (*BindGroupLayout) Destroy

func (l *BindGroupLayout) Destroy()

Destroy is a no-op for bind group layouts.

type BindGroupLayoutDescriptor

type BindGroupLayoutDescriptor = hal.BindGroupLayoutDescriptor

Type aliases for hal descriptors

type BindGroupLayoutInfo added in v0.23.8

type BindGroupLayoutInfo struct {
	BindingToSlot []uint8 // indexed by binding number, 0xFF = unused
}

BindGroupLayoutInfo stores per-group binding-to-slot mapping computed at PipelineLayout creation time. Matches Rust wgpu-hal BindGroupLayoutInfo. Each entry in BindingToSlot is indexed by the WGSL binding number and maps to the sequential GL slot index for that resource type. 0xFF means unused.

type BindSamplerCommand

type BindSamplerCommand struct {
	// contains filtered or unexported fields
}

BindSamplerCommand binds a sampler object to a texture unit; sampler 0 unbinds it (Rust gles Command::BindSampler).

func (*BindSamplerCommand) Execute

func (c *BindSamplerCommand) Execute(ctx *gl.Context)

type BindSurfaceFramebufferCommand added in v0.25.0

type BindSurfaceFramebufferCommand struct {
	// contains filtered or unexported fields
}

BindSurfaceFramebufferCommand binds the Surface's swapchain offscreen framebuffer. Reads surface.swapchainFBO at execute time so reconfigure (e.g. window resize) between encode and submit is handled correctly. Mirrors Rust wgpu-hal/src/gles/egl.rs Surface::configure swapchain FBO.

func (*BindSurfaceFramebufferCommand) Execute added in v0.25.0

func (c *BindSurfaceFramebufferCommand) Execute(ctx *gl.Context)

type BindVAOCommand added in v0.16.0

type BindVAOCommand struct {
	// contains filtered or unexported fields
}

BindVAOCommand binds a vertex array object.

func (*BindVAOCommand) Execute added in v0.16.0

func (c *BindVAOCommand) Execute(ctx *gl.Context)

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer implements hal.Buffer for OpenGL.

func (*Buffer) Destroy

func (b *Buffer) Destroy()

Destroy releases the buffer.

func (*Buffer) NativeHandle added in v0.12.0

func (b *Buffer) NativeHandle() uintptr

NativeHandle returns the GL buffer object ID.

type BufferDescriptor

type BufferDescriptor = hal.BufferDescriptor

Type aliases for hal descriptors

type ClearBufferCommand

type ClearBufferCommand struct {
	// contains filtered or unexported fields
}

ClearBufferCommand clears a buffer region.

func (*ClearBufferCommand) Execute

func (c *ClearBufferCommand) Execute(_ *gl.Context)

type ClearColorBufferCommand added in v0.31.8

type ClearColorBufferCommand struct {
	// contains filtered or unexported fields
}

ClearColorBufferCommand clears a specific color draw buffer with glClearBufferfv, glClearBufferuiv or glClearBufferiv, by the sample type of the attachment's format: Rust wgpu-hal GLES ClearColorF, ClearColorU and ClearColorI (command.rs:656-671). glClearBufferfv on an integer buffer leaves it undefined, and no integer target held its clear value. Per-buffer clears replace the old global glClearColor+glClear so each attachment of an MRT pass gets its own clear value.

func (*ClearColorBufferCommand) Execute added in v0.31.8

func (c *ClearColorBufferCommand) Execute(ctx *gl.Context)

type ClearColorCommand

type ClearColorCommand struct {
	// contains filtered or unexported fields
}

ClearColorCommand clears a color attachment using the legacy global clear path. Retained for backward compatibility with tests and single-target code paths. For MRT, use ClearColorBufferCommand instead (per-buffer via glClearBufferfv).

func (*ClearColorCommand) Execute

func (c *ClearColorCommand) Execute(ctx *gl.Context)

type ClearDepthCommand

type ClearDepthCommand struct {
	// contains filtered or unexported fields
}

ClearDepthCommand clears the depth buffer.

func (*ClearDepthCommand) Execute

func (c *ClearDepthCommand) Execute(ctx *gl.Context)

type ClearStencilCommand

type ClearStencilCommand struct {
	// contains filtered or unexported fields
}

ClearStencilCommand clears the stencil buffer.

func (*ClearStencilCommand) Execute

func (c *ClearStencilCommand) Execute(ctx *gl.Context)

type ColorTargetDesc added in v0.31.8

type ColorTargetDesc struct {
	Blend     *gputypes.BlendState
	WriteMask gputypes.ColorWriteMask
}

ColorTargetDesc describes per-render-target blend and write mask state. Matches Rust wgpu-hal GLES ColorTargetDesc (mod.rs:770-773).

type Command

type Command interface {
	Execute(ctx *gl.Context)
}

Command represents a recorded GL command.

type CommandBuffer

type CommandBuffer struct {
	// contains filtered or unexported fields
}

CommandBuffer holds recorded commands for later execution.

func (*CommandBuffer) Destroy

func (c *CommandBuffer) Destroy()

Destroy releases the command buffer resources.

type CommandEncoder

type CommandEncoder struct {
	// contains filtered or unexported fields
}

CommandEncoder implements hal.CommandEncoder for OpenGL. Platform-specific fields are defined in command_<platform>.go files.

func (*CommandEncoder) BeginComputePass

func (e *CommandEncoder) BeginComputePass(desc *hal.ComputePassDescriptor) hal.ComputePassEncoder

BeginComputePass begins a compute pass.

func (*CommandEncoder) BeginEncoding

func (e *CommandEncoder) BeginEncoding(label string) error

BeginEncoding begins command recording.

func (*CommandEncoder) BeginRenderPass

func (e *CommandEncoder) BeginRenderPass(desc *hal.RenderPassDescriptor) hal.RenderPassEncoder

BeginRenderPass begins a render pass.

func (*CommandEncoder) BuildAccelerationStructures added in v0.32.0

func (e *CommandEncoder) BuildAccelerationStructures(_ []hal.BuildAccelerationStructureDescriptor)

BuildAccelerationStructures is a no-op (GLES has no ray tracing).

func (*CommandEncoder) ClearBuffer

func (e *CommandEncoder) ClearBuffer(buffer hal.Buffer, offset, size uint64)

ClearBuffer clears a buffer region to zero.

func (*CommandEncoder) CopyAccelerationStructure added in v0.32.0

func (e *CommandEncoder) CopyAccelerationStructure(_, _ hal.AccelerationStructure, _ gputypes.AccelerationStructureCopyMode)

CopyAccelerationStructure is a no-op (GLES has no ray tracing).

func (*CommandEncoder) CopyBufferToBuffer

func (e *CommandEncoder) CopyBufferToBuffer(src, dst hal.Buffer, regions []hal.BufferCopy)

CopyBufferToBuffer copies data between buffers.

func (*CommandEncoder) CopyBufferToTexture

func (e *CommandEncoder) CopyBufferToTexture(src hal.Buffer, dst hal.Texture, regions []hal.BufferTextureCopy)

CopyBufferToTexture copies buffer data to a texture via PBO (pixel unpack buffer). Binds the source buffer as GL_PIXEL_UNPACK_BUFFER, then calls glTexSubImage2D with offset 0 so that GL reads pixel data from the bound PBO. Matches Rust wgpu-hal/src/gles/queue.rs CopyBufferToTexture command.

func (*CommandEncoder) CopyTextureToBuffer

func (e *CommandEncoder) CopyTextureToBuffer(src hal.Texture, dst hal.Buffer, regions []hal.BufferTextureCopy)

CopyTextureToBuffer copies texture data to a buffer via FBO + glReadPixels. For each region, it binds the source texture's FBO and reads pixels into the destination buffer's CPU-side data slice.

func (*CommandEncoder) CopyTextureToTexture

func (e *CommandEncoder) CopyTextureToTexture(src, dst hal.Texture, regions []hal.TextureCopy)

CopyTextureToTexture copies between textures using FBO read + glCopyTexSubImage2D. Attaches the source texture to the read framebuffer, then copies pixels into the destination texture. This works on GL 3.0+ / ES 3.0+ without glCopyImageSubData. Matches Rust wgpu-hal/src/gles/queue.rs CopyTextureToTexture command.

func (*CommandEncoder) Destroy added in v0.23.4

func (e *CommandEncoder) Destroy()

Destroy is a no-op for OpenGL (no persistent GPU resources owned by encoder).

func (*CommandEncoder) DiscardEncoding

func (e *CommandEncoder) DiscardEncoding()

DiscardEncoding discards the encoder.

func (*CommandEncoder) EndEncoding

func (e *CommandEncoder) EndEncoding() (hal.CommandBuffer, error)

EndEncoding finishes command recording and returns a command buffer.

func (*CommandEncoder) PlaceAccelerationStructureBarrier added in v0.32.0

func (e *CommandEncoder) PlaceAccelerationStructureBarrier(_ hal.AccelerationStructureBarrier)

PlaceAccelerationStructureBarrier is a no-op (GLES has no ray tracing).

func (*CommandEncoder) ReadAccelerationStructureCompactSize added in v0.32.0

func (e *CommandEncoder) ReadAccelerationStructureCompactSize(_ hal.AccelerationStructure, _ hal.Buffer, _ uint64)

ReadAccelerationStructureCompactSize is a no-op (GLES has no ray tracing).

func (*CommandEncoder) ResetAll

func (e *CommandEncoder) ResetAll(_ []hal.CommandBuffer)

ResetAll resets command buffers for reuse.

func (*CommandEncoder) ResolveQuerySet added in v0.16.4

func (e *CommandEncoder) ResolveQuerySet(querySet hal.QuerySet, firstQuery, queryCount uint32, destination hal.Buffer, destinationOffset uint64)

ResolveQuerySet copies query results from a query set into a destination buffer. Each result is a uint64 (8 bytes) written starting at destinationOffset. Uses glGetQueryObjectui64v to read results, then glBufferSubData to write them. Matches Rust wgpu-hal/src/gles/queue.rs CopyQueryResults command (fallback path).

func (*CommandEncoder) TransitionBuffers

func (e *CommandEncoder) TransitionBuffers(barriers []hal.BufferBarrier)

TransitionBuffers emits memory barriers for buffer state transitions. GLES only needs explicit barriers when transitioning FROM storage write (compute shader output) to any other usage (vertex, uniform, draw). Matches Rust wgpu-hal/gles command.rs:279-298.

func (*CommandEncoder) TransitionTextures

func (e *CommandEncoder) TransitionTextures(barriers []hal.TextureBarrier)

TransitionTextures emits memory barriers for texture state transitions. GLES only needs explicit barriers when transitioning FROM storage write to any other usage (texture fetch, framebuffer attachment). Matches Rust wgpu-hal/gles command.rs:300-327.

type CommandEncoderDescriptor

type CommandEncoderDescriptor = hal.CommandEncoderDescriptor

Type aliases for hal descriptors

type ComputePassEncoder

type ComputePassEncoder struct {
	// contains filtered or unexported fields
}

ComputePassEncoder implements hal.ComputePassEncoder for OpenGL.

func (*ComputePassEncoder) Dispatch

func (e *ComputePassEncoder) Dispatch(x, y, z uint32)

Dispatch dispatches compute work.

func (*ComputePassEncoder) DispatchIndirect

func (e *ComputePassEncoder) DispatchIndirect(buffer hal.Buffer, offset uint64)

DispatchIndirect dispatches compute work with GPU-generated parameters.

func (*ComputePassEncoder) End

func (e *ComputePassEncoder) End()

End finishes the compute pass.

func (*ComputePassEncoder) SetBindGroup

func (e *ComputePassEncoder) SetBindGroup(index uint32, group hal.BindGroup, offsets []uint32)

SetBindGroup sets a bind group.

func (*ComputePassEncoder) SetPipeline

func (e *ComputePassEncoder) SetPipeline(pipeline hal.ComputePipeline)

SetPipeline sets the compute pipeline.

type ComputePipeline

type ComputePipeline struct {
	// contains filtered or unexported fields
}

ComputePipeline implements hal.ComputePipeline for OpenGL.

func (*ComputePipeline) Destroy

func (p *ComputePipeline) Destroy()

Destroy releases the compute pipeline.

type ComputePipelineDescriptor

type ComputePipelineDescriptor = hal.ComputePipelineDescriptor

Type aliases for hal descriptors

type CopyBufferCommand

type CopyBufferCommand struct {
	// contains filtered or unexported fields
}

CopyBufferCommand copies a region of one GL buffer object into another.

func (*CopyBufferCommand) Execute

func (c *CopyBufferCommand) Execute(ctx *gl.Context)

Execute performs the copy with glCopyBufferSubData through the dedicated COPY_READ_BUFFER / COPY_WRITE_BUFFER binding points, so the copy does not disturb the buffers bound to the vertex, index or uniform targets. Mirrors Rust wgpu-hal gles/queue.rs C::CopyBufferToBuffer (raw → raw case). Desktop GL and GLES 3.0 allow any buffer role on the copy targets; the ELEMENT_ARRAY_BUFFER special case in Rust exists only for WebGL.

type CopyBufferToTextureCommand added in v0.28.4

type CopyBufferToTextureCommand struct {
	// contains filtered or unexported fields
}

CopyBufferToTextureCommand copies buffer data to a texture using a pixel unpack buffer. Binds the source GL buffer as GL_PIXEL_UNPACK_BUFFER, then calls glTexSubImage2D (glTexSubImage3D for a 3D or 2D array texture) with the buffer offset as the pixels pointer, so GL reads from the bound PBO. Matches Rust wgpu-hal/src/gles/queue.rs CopyBufferToTexture.

func (*CopyBufferToTextureCommand) Execute added in v0.28.4

func (c *CopyBufferToTextureCommand) Execute(ctx *gl.Context)

type CopyTextureToBufferCommand added in v0.16.0

type CopyTextureToBufferCommand struct {
	// contains filtered or unexported fields
}

CopyTextureToBufferCommand reads pixels from a texture's FBO into a buffer's CPU-side data slice. This is the standard GLES readback path since GLES lacks glGetTexImage. The approach: bind texture FBO -> glReadPixels -> copy to buffer.

func (*CopyTextureToBufferCommand) Execute added in v0.16.0

func (c *CopyTextureToBufferCommand) Execute(ctx *gl.Context)

Execute reads pixels from the source texture's FBO into the destination buffer.

type CopyTextureToTextureCommand added in v0.28.4

type CopyTextureToTextureCommand struct {
	// contains filtered or unexported fields
}

CopyTextureToTextureCommand copies pixels between textures using an FBO. Attaches the source texture to GL_READ_FRAMEBUFFER, then copies into the destination via glCopyTexSubImage2D. Matches Rust wgpu-hal/src/gles/queue.rs CopyTextureToTexture.

func (*CopyTextureToTextureCommand) Execute added in v0.28.4

func (c *CopyTextureToTextureCommand) Execute(ctx *gl.Context)

type Device

type Device struct {
	// contains filtered or unexported fields
}

Device implements hal.Device for OpenGL on Linux. Holds a reference to its *AdapterContext from Adapter.Open to Destroy; the Queue borrows it. All GL operations acquire the context lock, do MakeCurrent, execute, and unlock.

func (*Device) CreateAccelerationStructure added in v0.32.0

func (d *Device) CreateAccelerationStructure(_ *hal.AccelerationStructureDescriptor) (hal.AccelerationStructure, error)

CreateAccelerationStructure returns an error because the GLES backend does not support ray tracing. OpenGL ES has no acceleration structure API.

func (*Device) CreateBindGroup

func (d *Device) CreateBindGroup(desc *BindGroupDescriptor) (hal.BindGroup, error)

CreateBindGroup creates a bind group.

func (*Device) CreateBindGroupLayout

func (d *Device) CreateBindGroupLayout(desc *BindGroupLayoutDescriptor) (hal.BindGroupLayout, error)

CreateBindGroupLayout creates a bind group layout.

func (*Device) CreateBuffer

func (d *Device) CreateBuffer(desc *BufferDescriptor) (hal.Buffer, error)

CreateBuffer creates a GPU buffer.

func (*Device) CreateCommandEncoder

func (d *Device) CreateCommandEncoder(_ *CommandEncoderDescriptor) (hal.CommandEncoder, error)

CreateCommandEncoder creates a command encoder. VAO is lazily created on first call — ensures it's allocated on the window surface (after Configure), not on the pbuffer (during Open). Mesa d3d12 gallium invalidates GL objects when switching from pbuffer to window surface.

func (*Device) CreateComputePipeline

func (d *Device) CreateComputePipeline(desc *ComputePipelineDescriptor) (hal.ComputePipeline, error)

CreateComputePipeline creates a compute pipeline.

desc.Compute.Constants are applied by compileWGSLToGLSL (naga.ProcessOverrides before GLSL emission, Rust gles/device.rs:385).

TODO(zero-init-workgroup): Pass desc.Compute.ZeroInitializeWorkgroupMemory to naga GLSL options. Rust wgpu-hal sets naga_options.zero_initialize_workgroup_memory per-stage (gles/device.rs:268).

func (*Device) CreateFence

func (d *Device) CreateFence() (hal.Fence, error)

CreateFence creates a synchronization fence.

func (*Device) CreatePipelineLayout

func (d *Device) CreatePipelineLayout(desc *PipelineLayoutDescriptor) (hal.PipelineLayout, error)

CreatePipelineLayout creates a pipeline layout. Computes per-type sequential binding indices following the Rust wgpu-hal pattern (wgpu-hal/src/gles/device.rs:1154-1221). Five resource type counters (samplers, textures, images, uniform buffers, storage buffers) are incremented sequentially across all bind group layouts, producing a flat GL slot index per binding.

func (*Device) CreateQuerySet added in v0.16.4

func (d *Device) CreateQuerySet(_ *hal.QuerySetDescriptor) (hal.QuerySet, error)

CreateQuerySet creates a query set. TODO: implement using GL_EXT_disjoint_timer_query for timestamp support.

func (*Device) CreateRenderBundleEncoder added in v0.13.0

func (d *Device) CreateRenderBundleEncoder(desc *hal.RenderBundleEncoderDescriptor) (hal.RenderBundleEncoder, error)

CreateRenderBundleEncoder is not supported in GLES backend.

func (*Device) CreateRenderPipeline

func (d *Device) CreateRenderPipeline(desc *RenderPipelineDescriptor) (hal.RenderPipeline, error)

CreateRenderPipeline creates a render pipeline.

func (*Device) CreateSampler

func (d *Device) CreateSampler(desc *SamplerDescriptor) (hal.Sampler, error)

CreateSampler creates a texture sampler using GL sampler objects (GL 3.3+).

func (*Device) CreateShaderModule

func (d *Device) CreateShaderModule(desc *ShaderModuleDescriptor) (hal.ShaderModule, error)

CreateShaderModule creates a shader module.

func (*Device) CreateTexture

func (d *Device) CreateTexture(desc *TextureDescriptor) (hal.Texture, error)

CreateTexture creates a GPU texture.

func (*Device) CreateTextureView

func (d *Device) CreateTextureView(texture hal.Texture, desc *TextureViewDescriptor) (hal.TextureView, error)

CreateTextureView creates a view into a texture. Accepts both *Texture and *SurfaceTexture (default framebuffer).

func (*Device) Destroy

func (d *Device) Destroy()

Destroy releases the device: its VAO, then the Device's reference to its context (taken by Adapter.Open), the last of which destroys the context. The root Device releases the HAL device last, after every resource of it.

func (*Device) DestroyAccelerationStructure added in v0.32.0

func (d *Device) DestroyAccelerationStructure(_ hal.AccelerationStructure)

DestroyAccelerationStructure is a no-op (GLES has no ray tracing).

func (*Device) DestroyBindGroup

func (d *Device) DestroyBindGroup(group hal.BindGroup)

DestroyBindGroup destroys a bind group.

func (*Device) DestroyBindGroupLayout

func (d *Device) DestroyBindGroupLayout(layout hal.BindGroupLayout)

DestroyBindGroupLayout destroys a bind group layout.

func (*Device) DestroyBuffer

func (d *Device) DestroyBuffer(buffer hal.Buffer)

DestroyBuffer destroys a GPU buffer. Caller must not hold the AdapterContext lock; this method acquires it so glDeleteBuffers runs with a current context after Unlock unmakes between ops.

func (*Device) DestroyComputePipeline

func (d *Device) DestroyComputePipeline(pipeline hal.ComputePipeline)

DestroyComputePipeline destroys a compute pipeline.

func (*Device) DestroyFence

func (d *Device) DestroyFence(fence hal.Fence)

DestroyFence destroys a fence.

func (*Device) DestroyPipelineLayout

func (d *Device) DestroyPipelineLayout(layout hal.PipelineLayout)

DestroyPipelineLayout destroys a pipeline layout.

func (*Device) DestroyQuerySet added in v0.16.4

func (d *Device) DestroyQuerySet(_ hal.QuerySet)

DestroyQuerySet destroys a query set. Stub — add Lock when GL query objects are implemented.

func (*Device) DestroyRenderBundle added in v0.13.0

func (d *Device) DestroyRenderBundle(bundle hal.RenderBundle)

DestroyRenderBundle is not supported in GLES backend.

func (*Device) DestroyRenderPipeline

func (d *Device) DestroyRenderPipeline(pipeline hal.RenderPipeline)

DestroyRenderPipeline destroys a render pipeline.

func (*Device) DestroySampler

func (d *Device) DestroySampler(sampler hal.Sampler)

DestroySampler destroys a sampler.

func (*Device) DestroyShaderModule

func (d *Device) DestroyShaderModule(module hal.ShaderModule)

DestroyShaderModule destroys a shader module.

func (*Device) DestroyTexture

func (d *Device) DestroyTexture(texture hal.Texture)

DestroyTexture destroys a GPU texture.

func (*Device) DestroyTextureView

func (d *Device) DestroyTextureView(view hal.TextureView)

DestroyTextureView destroys a texture view. It holds no GL object; this only drops its handle.

func (*Device) FreeCommandBuffer added in v0.13.0

func (d *Device) FreeCommandBuffer(cmdBuffer hal.CommandBuffer)

FreeCommandBuffer is a no-op for GLES. GLES doesn't have Vulkan-style command pools - commands are recorded directly.

func (*Device) GetAccelerationStructureBuildSizes added in v0.32.0

GetAccelerationStructureBuildSizes returns zero sizes (GLES has no ray tracing).

func (*Device) GetAccelerationStructureDeviceAddress added in v0.32.0

func (d *Device) GetAccelerationStructureDeviceAddress(_ hal.AccelerationStructure) uint64

GetAccelerationStructureDeviceAddress returns 0 (GLES has no ray tracing).

func (*Device) GetFenceStatus added in v0.13.0

func (d *Device) GetFenceStatus(fence hal.Fence) (bool, error)

GetFenceStatus returns true if the fence is signaled (non-blocking).

func (*Device) MapBuffer added in v0.25.0

func (d *Device) MapBuffer(buffer hal.Buffer, offset, size uint64) (hal.BufferMapping, error)

MapBuffer establishes a CPU-visible mapping for a GL buffer via a CPU shadow slice. See device.go (Windows variant) for rationale.

func (*Device) ResetFence added in v0.13.0

func (d *Device) ResetFence(fence hal.Fence) error

ResetFence resets a fence to the unsignaled state.

func (*Device) RobustAccess

func (d *Device) RobustAccess() bool

RobustAccess reports whether the device's GL context was created with robust buffer access, which makes the driver contain out-of-bounds buffer accesses from shaders: naga's GLSL output leaves them unchecked, as Rust's does. EGL requests it as Rust wgpu-hal does; WGL requests it too, beyond Rust (wgl.CreateRobustContext).

func (*Device) TlasInstanceToBytes added in v0.32.0

func (d *Device) TlasInstanceToBytes(_ hal.TlasInstance) []byte

TlasInstanceToBytes returns nil (GLES has no ray tracing).

func (*Device) UnmapBuffer added in v0.25.0

func (d *Device) UnmapBuffer(buffer hal.Buffer) error

UnmapBuffer releases a GL buffer mapping. Writable buffers push the shadow back into the GL buffer via glBufferSubData; the shadow is then released so subsequent MapBuffer calls pick up fresh contents.

func (*Device) Wait

func (d *Device) Wait(fence hal.Fence, value uint64, timeout time.Duration) (bool, error)

Wait waits for a fence to reach the specified value.

func (*Device) WaitIdle added in v0.16.3

func (d *Device) WaitIdle() error

WaitIdle waits for all GPU work to complete.

type DisableVertexAttribsCommand

type DisableVertexAttribsCommand struct {
	// contains filtered or unexported fields
}

DisableVertexAttribsCommand disables vertex attribute arrays.

func (*DisableVertexAttribsCommand) Execute

func (c *DisableVertexAttribsCommand) Execute(ctx *gl.Context)

type DispatchCommand

type DispatchCommand struct {
	// contains filtered or unexported fields
}

DispatchCommand dispatches compute work.

func (*DispatchCommand) Execute

func (c *DispatchCommand) Execute(ctx *gl.Context)

Execute dispatches compute work and inserts a memory barrier.

type DispatchIndirectCommand added in v0.8.1

type DispatchIndirectCommand struct {
	// contains filtered or unexported fields
}

DispatchIndirectCommand dispatches compute work with GPU-generated parameters.

func (*DispatchIndirectCommand) Execute added in v0.8.1

func (c *DispatchIndirectCommand) Execute(ctx *gl.Context)

Execute dispatches compute work from indirect buffer and inserts a memory barrier.

type DrawCommand

type DrawCommand struct {
	// contains filtered or unexported fields
}

DrawCommand executes a non-indexed draw (Rust wgpu-hal gles/queue.rs C::Draw). It always draws instanced: ANGLE ignores the instance divisor in glDrawArrays (gfx-rs/wgpu#3578).

func (*DrawCommand) Execute

func (c *DrawCommand) Execute(ctx *gl.Context)

type DrawIndexedCommand

type DrawIndexedCommand struct {
	// contains filtered or unexported fields
}

DrawIndexedCommand executes an indexed draw (Rust wgpu-hal gles/queue.rs C::DrawIndexed): the index buffer offset plus firstIndex elements, the base vertex, and the first instance as for DrawCommand.

func (*DrawIndexedCommand) Execute

func (c *DrawIndexedCommand) Execute(ctx *gl.Context)

type DrawIndexedIndirectCommand

type DrawIndexedIndirectCommand struct {
	// contains filtered or unexported fields
}

DrawIndexedIndirectCommand draws count DrawIndexedIndirectArgs records (Rust wgpu-hal gles/queue.rs C::DrawIndexedIndirect), as DrawIndirectCommand.

glDrawElementsIndirect has no index buffer offset: a record's firstIndex counts from the start of the bound GL_ELEMENT_ARRAY_BUFFER, and the record lives on the GPU, so it cannot be patched on the CPU. With a nonzero SetIndexBuffer offset the draw therefore binds a GPU copy of the index buffer from that offset (glCopyBufferSubData) and restores the original binding afterwards. Rust wgpu-hal gles ignores the offset here (P1-GLES-018).

func (*DrawIndexedIndirectCommand) Execute

func (c *DrawIndexedIndirectCommand) Execute(ctx *gl.Context)

type DrawIndirectCommand

type DrawIndirectCommand struct {
	// contains filtered or unexported fields
}

DrawIndirectCommand draws count DrawIndirectArgs records (Rust wgpu-hal gles/queue.rs C::DrawIndirect). The first instance in a record reaches GL only with fully featured instancing; the uniform is 0. Several records go to one glMultiDrawArraysIndirect where the context has it, so gl_DrawID (draw_index) counts them; Rust issues one draw per record, and offers no MultiDrawIndirect on GLES.

func (*DrawIndirectCommand) Execute

func (c *DrawIndirectCommand) Execute(ctx *gl.Context)

type EnsureOffscreenFBOCommand added in v0.16.0

type EnsureOffscreenFBOCommand struct {
	// contains filtered or unexported fields
}

EnsureOffscreenFBOCommand lazily creates a framebuffer object for an offscreen texture, binds it and attaches the pass's mip level as COLOR_ATTACHMENT0.

func (*EnsureOffscreenFBOCommand) Execute added in v0.16.0

func (c *EnsureOffscreenFBOCommand) Execute(ctx *gl.Context)

type Fence

type Fence struct {
	// contains filtered or unexported fields
}

Fence implements hal.Fence using GL sync objects (glFenceSync). Tracks pending GL sync objects and polls their completion status. Matches Rust wgpu-hal/src/gles/fence.rs Fence struct.

func NewFence

func NewFence(glCtx *gl.Context) *Fence

NewFence creates a new fence.

func (*Fence) Destroy

func (f *Fence) Destroy()

Destroy releases all fence resources. Matches Rust wgpu-hal/src/gles/fence.rs Fence::destroy.

func (*Fence) GetLatest added in v0.28.4

func (f *Fence) GetLatest() uint64

GetLatest polls pending sync objects and returns the highest completed value. Matches Rust wgpu-hal/src/gles/fence.rs Fence::get_latest.

func (*Fence) GetValue

func (f *Fence) GetValue() uint64

GetValue returns the current fence value (non-blocking poll).

func (*Fence) Maintain added in v0.28.4

func (f *Fence) Maintain()

Maintain cleans up completed sync objects. Matches Rust wgpu-hal/src/gles/fence.rs Fence::maintain.

func (*Fence) Reset added in v0.13.0

func (f *Fence) Reset()

Reset resets the fence to the unsignaled state.

func (*Fence) Signal

func (f *Fence) Signal(value uint64) error

Signal inserts a GL fence sync object into the command stream at the given value. Must be called on the GL thread BEFORE glFlush — the flush sends both the preceding commands and this fence to the GPU together. Returns an error if glFenceSync fails (typically OOM). Matches Rust wgpu-hal/src/gles/fence.rs Fence::signal.

func (*Fence) Wait

func (f *Fence) Wait(waitValue uint64, timeout time.Duration) bool

Wait waits for the fence to reach the specified value with timeout. Matches Rust wgpu-hal/src/gles/fence.rs Fence::wait.

type Instance

type Instance struct {
	// contains filtered or unexported fields
}

Instance implements hal.Instance for the OpenGL backend on Linux.

ctx is the instance context, created at init on our own X connection, the surfaceless platform or the caller's instance display, and held strongly until Destroy. Contexts built in CreateSurface on a caller's display (Path B: Wayland, or a window kind the instance context does not serve) belong to their surfaces and devices (ADR-077 B). The Instance keeps only weak pointers to them, keyed by native display, so later surfaces of the same display share the context.

func (*Instance) CreateSurface

func (i *Instance) CreateSurface(target hal.SurfaceTarget) (hal.Surface, error)

CreateSurface creates an OpenGL surface from window handles. On Linux: displayHandle and windowHandle are platform-specific. For X11: displayHandle is X11 Display*, windowHandle is Window. For Wayland: displayHandle is wl_display*, windowHandle is wl_surface*.

The surface uses the first context that serves its target (ADR-077):

  1. the instance context, by window kind. X11 XIDs are server-global, so a window of the app's Display* works with a context on our connection.
  2. a context an earlier surface built on the same native display;
  3. a new context on the caller's display (Path B: Wayland, where EGL needs the app's wl_display*, or a window kind the instance context does not serve). It lives as long as the surfaces and devices that use it.

The surface holds a reference to its context until Destroy.

func (*Instance) Destroy

func (i *Instance) Destroy()

Destroy releases the instance's own context. Contexts built on a caller's display are left to the surfaces and devices that hold them; the Instance only forgets them.

func (*Instance) EnumerateAdapters

func (i *Instance) EnumerateAdapters(surfaceHint hal.Surface) []hal.ExposedAdapter

EnumerateAdapters returns available OpenGL adapters. Uses surface context (preferred), instance context (X11/headless), or placeholder. The adapters hold their context weakly: a Device opened from one takes its own reference, and Open fails once the context is gone.

type MSAAResolveCommand added in v0.16.0

type MSAAResolveCommand struct {
	// contains filtered or unexported fields
}

MSAAResolveCommand resolves an MSAA framebuffer to a single-sample framebuffer using glBlitFramebuffer. This is recorded at render pass End() when a ResolveTarget is specified in the color attachment.

When resolveToSurface is true, the destination is the Surface's swapchain offscreen FBO (NOT FBO 0). No Y-flip is applied here — the Y-flip is the sole responsibility of Queue.Present, which blits the swapchain FBO to FBO 0 with srcY0=height, srcY1=0 before SwapBuffers. Mirrors Rust wgpu-hal: MSAA resolve lands in an offscreen target, present blit un-flips.

func (*MSAAResolveCommand) Execute added in v0.16.0

func (c *MSAAResolveCommand) Execute(ctx *gl.Context)

type MemoryBarrierCommand added in v0.27.2

type MemoryBarrierCommand struct {
	// contains filtered or unexported fields
}

MemoryBarrierCommand inserts a glMemoryBarrier call. Ensures compute shader writes are visible to subsequent draw/dispatch commands.

func (*MemoryBarrierCommand) Execute added in v0.27.2

func (c *MemoryBarrierCommand) Execute(ctx *gl.Context)

type PipelineLayout

type PipelineLayout struct {
	// contains filtered or unexported fields
}

PipelineLayout implements hal.PipelineLayout for OpenGL. Stores pre-computed per-type sequential binding indices (Rust wgpu pattern). The BindingMap is used by naga GLSL writer, GroupInfos by SetBindGroup at runtime.

func (*PipelineLayout) Destroy

func (l *PipelineLayout) Destroy()

Destroy is a no-op for pipeline layouts.

type PipelineLayoutDescriptor

type PipelineLayoutDescriptor = hal.PipelineLayoutDescriptor

Type aliases for hal descriptors

type QuerySet added in v0.28.4

type QuerySet struct {
	// contains filtered or unexported fields
}

QuerySet implements hal.QuerySet for OpenGL. Stores GL query object IDs and the target type (GL_TIMESTAMP or GL_ANY_SAMPLES_PASSED). Matches Rust wgpu-hal/src/gles/mod.rs QuerySet struct.

func (*QuerySet) Destroy added in v0.28.4

func (q *QuerySet) Destroy()

Destroy releases all GL query objects.

func (*QuerySet) NativeHandle added in v0.28.4

func (q *QuerySet) NativeHandle() uintptr

NativeHandle returns 0 (no single native handle for a query set).

func (*QuerySet) Target added in v0.28.4

func (q *QuerySet) Target() uint32

Target returns the GL query target type (GL_TIMESTAMP or GL_ANY_SAMPLES_PASSED).

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue implements hal.Queue for OpenGL on Linux. Holds a shared *AdapterContext (owned by Instance or Surface).

func (*Queue) GetTimestampPeriod

func (q *Queue) GetTimestampPeriod() float32

GetTimestampPeriod returns the timestamp period in nanoseconds.

func (*Queue) PollCompleted added in v0.23.0

func (q *Queue) PollCompleted() uint64

PollCompleted returns the highest submission index known to be completed. Polls pending GL sync objects via glGetSynciv (non-blocking, no flush). Safe because Submit() always flushes after inserting the fence — the fence is guaranteed to be in the GPU command queue by the time we poll it. Maintenance (cleanup of completed sync objects) happens in Submit(), not here (matches Rust wgpu-hal device.rs:1564 get_fence_value).

func (*Queue) Present

func (q *Queue) Present(surface hal.Surface, _ hal.SurfaceTexture, damageRects []image.Rectangle) error

Present presents a surface texture to the screen.

Makes the GL context current on the window EGLSurface (via LockForSurface), blits the Surface's swapchain offscreen FBO to the default framebuffer with an explicit Y-flip, then SwapBuffers. Mirrors Rust wgpu-hal src/gles/egl.rs Surface::present (1280-1308) and Windows LockForDC present.

damageRects is an optional list of rectangles (physical pixels, top-left origin) indicating which surface regions changed this frame. When non-empty and EGL_KHR_swap_buffers_with_damage is available, the rects are passed to eglSwapBuffersWithDamageKHR as compositor hints. EGL uses bottom-left origin, so Y coordinates are flipped here. When the extension is unavailable or no rects are provided, the standard eglSwapBuffers path is used.

func (*Queue) SetSwapchainSuppressed added in v0.26.3

func (q *Queue) SetSwapchainSuppressed(_ bool)

SetSwapchainSuppressed is a no-op on GLES. GLES uses eglSwapBuffers for presentation, which is not affected by command submission ordering. See BUG-WGPU-VK-005 (Vulkan-specific).

func (*Queue) Submit

func (q *Queue) Submit(commandBuffers []hal.CommandBuffer) (uint64, error)

Submit submits command buffers to the GPU. Acquires the AdapterContext lock, makes context current on pbuffer/surfaceless, executes all GL commands, signals the fence, and flushes.

func (*Queue) SupportsCommandBufferCopies added in v0.23.4

func (q *Queue) SupportsCommandBufferCopies() bool

SupportsCommandBufferCopies returns false for GLES on Linux. GLES uses direct GL calls for writes, not command buffer copy operations.

func (*Queue) WriteBuffer

func (q *Queue) WriteBuffer(buffer hal.Buffer, offset uint64, data []byte) error

WriteBuffer writes data to a buffer immediately.

func (*Queue) WriteTexture

func (q *Queue) WriteTexture(dst *hal.ImageCopyTexture, data []byte, layout *hal.ImageDataLayout, size *hal.Extent3D) error

WriteTexture writes data to a texture immediately.

type RenderPassEncoder

type RenderPassEncoder struct {
	// contains filtered or unexported fields
}

RenderPassEncoder implements hal.RenderPassEncoder for OpenGL.

func (*RenderPassEncoder) Draw

func (e *RenderPassEncoder) Draw(args gputypes.DrawArgs)

Draw draws primitives.

func (*RenderPassEncoder) DrawIndexed

func (e *RenderPassEncoder) DrawIndexed(args gputypes.DrawIndexedArgs)

DrawIndexed draws indexed primitives.

func (*RenderPassEncoder) DrawIndexedIndirect

func (e *RenderPassEncoder) DrawIndexedIndirect(buffer hal.Buffer, offset uint64, drawCount uint32)

DrawIndexedIndirect draws drawCount indexed records from offset in buffer (Rust wgpu-hal gles command.rs draw_indexed_indirect, queue.rs DrawIndexedIndirect). A nonzero SetIndexBuffer offset is applied as DrawIndexedIndirectCommand describes.

func (*RenderPassEncoder) DrawIndexedIndirectCount added in v0.34.3

func (e *RenderPassEncoder) DrawIndexedIndirectCount(_ hal.Buffer, _ uint64, _ hal.Buffer, _ uint64, _ uint32)

DrawIndexedIndirectCount is not supported by the GLES backend.

func (*RenderPassEncoder) DrawIndirect

func (e *RenderPassEncoder) DrawIndirect(buffer hal.Buffer, offset uint64, drawCount uint32)

DrawIndirect draws drawCount records from offset in buffer (Rust wgpu-hal gles command.rs draw_indirect, queue.rs DrawIndirect).

func (*RenderPassEncoder) DrawIndirectCount added in v0.34.3

func (e *RenderPassEncoder) DrawIndirectCount(_ hal.Buffer, _ uint64, _ hal.Buffer, _ uint64, _ uint32)

DrawIndirectCount is not supported by the GLES backend.

func (*RenderPassEncoder) End

func (e *RenderPassEncoder) End()

End finishes the render pass. If MSAA resolve is needed, blits the MSAA FBO to the resolve target FBO. If the pass was rendering to an offscreen FBO, rebinds the default framebuffer so subsequent operations do not accidentally target the offscreen texture.

func (*RenderPassEncoder) ExecuteBundle

func (e *RenderPassEncoder) ExecuteBundle(bundle hal.RenderBundle)

ExecuteBundle executes a pre-recorded render bundle. Note: Render bundles are not natively supported in OpenGL. OpenGL uses display lists (deprecated) or VAO/VBO state caching. This is a no-op - bundles are expanded inline in the command stream.

func (*RenderPassEncoder) SetBindGroup

func (e *RenderPassEncoder) SetBindGroup(index uint32, group hal.BindGroup, offsets []uint32)

SetBindGroup sets a bind group.

func (*RenderPassEncoder) SetBlendConstant

func (e *RenderPassEncoder) SetBlendConstant(color *gputypes.Color)

SetBlendConstant sets the blend constant.

func (*RenderPassEncoder) SetIndexBuffer

func (e *RenderPassEncoder) SetIndexBuffer(buffer hal.Buffer, format gputypes.IndexFormat, offset uint64)

SetIndexBuffer sets the index buffer.

func (*RenderPassEncoder) SetPipeline

func (e *RenderPassEncoder) SetPipeline(pipeline hal.RenderPipeline)

SetPipeline sets the render pipeline.

func (*RenderPassEncoder) SetScissorRect

func (e *RenderPassEncoder) SetScissorRect(rect gputypes.ScissorRect)

SetScissorRect sets the scissor rectangle. With ADJUST_COORDINATE_SPACE, no Y-flip is needed — coordinates pass through directly.

func (*RenderPassEncoder) SetStencilReference

func (e *RenderPassEncoder) SetStencilReference(ref uint32)

SetStencilReference sets the stencil reference value.

func (*RenderPassEncoder) SetVertexBuffer

func (e *RenderPassEncoder) SetVertexBuffer(slot uint32, buffer hal.Buffer, offset uint64)

SetVertexBuffer binds a vertex buffer to a slot. Its attributes are set up before the next draw, with the layout of the pipeline current then.

func (*RenderPassEncoder) SetViewport

func (e *RenderPassEncoder) SetViewport(vp gputypes.Viewport)

SetViewport sets the viewport.

type RenderPipeline

type RenderPipeline struct {
	// contains filtered or unexported fields
}

RenderPipeline implements hal.RenderPipeline for OpenGL.

func (*RenderPipeline) Destroy

func (p *RenderPipeline) Destroy()

Destroy releases the render pipeline.

type RenderPipelineDescriptor

type RenderPipelineDescriptor = hal.RenderPipelineDescriptor

Type aliases for hal descriptors

type ResolveQuerySetCommand added in v0.28.4

type ResolveQuerySetCommand struct {
	// contains filtered or unexported fields
}

ResolveQuerySetCommand reads query results via glGetQueryObjectui64v and writes them into the destination buffer via glBufferSubData. Uses the CPU fallback path (no QUERY_BUFFER) to stay compatible with GLES 3.0+ / GL 3.3+. Each result is a uint64 (8 bytes). Matches Rust wgpu-hal/src/gles/queue.rs CopyQueryResults (fallback path).

func (*ResolveQuerySetCommand) Execute added in v0.28.4

func (c *ResolveQuerySetCommand) Execute(ctx *gl.Context)

type Sampler

type Sampler struct {
	// contains filtered or unexported fields
}

Sampler implements hal.Sampler for OpenGL using GL sampler objects (GL 3.3+).

func (*Sampler) Destroy

func (s *Sampler) Destroy()

Destroy releases the GL sampler object.

func (*Sampler) NativeHandle added in v0.12.0

func (s *Sampler) NativeHandle() uintptr

NativeHandle returns the GL sampler object ID.

type SamplerDescriptor

type SamplerDescriptor = hal.SamplerDescriptor

Type aliases for hal descriptors

type SetBindGroupCommand

type SetBindGroupCommand struct {
	// contains filtered or unexported fields
}

SetBindGroupCommand binds resources.

func (*SetBindGroupCommand) Execute

func (c *SetBindGroupCommand) Execute(ctx *gl.Context)

type SetBlendConstantCommand

type SetBlendConstantCommand struct {
	// contains filtered or unexported fields
}

SetBlendConstantCommand sets blend constant.

func (*SetBlendConstantCommand) Execute

func (c *SetBlendConstantCommand) Execute(ctx *gl.Context)

type SetDrawColorBuffersCommand added in v0.31.8

type SetDrawColorBuffersCommand struct {
	// contains filtered or unexported fields
}

SetDrawColorBuffersCommand configures the list of draw buffers for MRT output. Matches Rust wgpu-hal GLES SetDrawColorBuffers (command.rs:643-646, queue.rs:1202-1207).

func (*SetDrawColorBuffersCommand) Execute added in v0.31.8

func (c *SetDrawColorBuffersCommand) Execute(ctx *gl.Context)

type SetIndexBufferCommand

type SetIndexBufferCommand struct {
	// contains filtered or unexported fields
}

SetIndexBufferCommand binds an index buffer.

func (*SetIndexBufferCommand) Execute

func (c *SetIndexBufferCommand) Execute(ctx *gl.Context)

type SetPipelineStateCommand

type SetPipelineStateCommand struct {
	// contains filtered or unexported fields
}

SetPipelineStateCommand sets pipeline state (culling, depth, stencil, blending, color mask).

func (*SetPipelineStateCommand) Execute

func (c *SetPipelineStateCommand) Execute(ctx *gl.Context)

type SetScissorCommand

type SetScissorCommand struct {
	// contains filtered or unexported fields
}

SetScissorCommand sets the scissor rectangle. With ADJUST_COORDINATE_SPACE enabled, the scene is rendered upside-down in GL. The scissor coordinates are passed through directly (no Y-flip needed) because the scissor operates in the same flipped coordinate space as the rendered content. This matches Rust wgpu-hal GLES which also passes scissor through without Y-flip.

func (*SetScissorCommand) Execute

func (c *SetScissorCommand) Execute(ctx *gl.Context)

type SetStencilRefCommand

type SetStencilRefCommand struct {
	// contains filtered or unexported fields
}

SetStencilRefCommand updates the stencil reference value. This re-applies glStencilFuncSeparate with the new reference while keeping the compare function and read mask from the current pipeline.

func (*SetStencilRefCommand) Execute

func (c *SetStencilRefCommand) Execute(ctx *gl.Context)

type SetVertexBufferCommand

type SetVertexBufferCommand struct {
	// contains filtered or unexported fields
}

SetVertexBufferCommand binds a vertex buffer and configures vertex attributes. In OpenGL, vertex attributes must be configured explicitly via glVertexAttribPointer + glEnableVertexAttribArray. The layout describes how vertex data is interpreted (attribute locations, formats, strides).

func (*SetVertexBufferCommand) Execute

func (c *SetVertexBufferCommand) Execute(ctx *gl.Context)

type SetViewportCommand

type SetViewportCommand struct {
	// contains filtered or unexported fields
}

SetViewportCommand sets the viewport.

func (*SetViewportCommand) Execute

func (c *SetViewportCommand) Execute(ctx *gl.Context)

type ShaderModule

type ShaderModule struct {
	// contains filtered or unexported fields
}

ShaderModule implements hal.ShaderModule for OpenGL.

func (*ShaderModule) Destroy

func (m *ShaderModule) Destroy()

Destroy releases the shader module.

type ShaderModuleDescriptor

type ShaderModuleDescriptor = hal.ShaderModuleDescriptor

Type aliases for hal descriptors

type Surface

type Surface struct {
	// contains filtered or unexported fields
}

Surface implements hal.Surface for OpenGL on Linux. The Surface holds one reference to its AdapterContext, from CreateSurface to Destroy (ADR-077 B): the instance context it shares, or the context built on the caller's display. A Device opened on the same context holds its own, so the context lives until the last of them is released, while the native display the caller keeps open for them is still alive.

func (*Surface) AcquireTexture

func (s *Surface) AcquireTexture(_ hal.Fence) (*hal.AcquiredSurfaceTexture, error)

AcquireTexture returns the next surface texture for rendering.

func (*Surface) ActualExtent added in v0.28.2

func (s *Surface) ActualExtent() (width, height uint32)

ActualExtent returns the configured surface dimensions. GLES does not clamp the extent, so these always match the requested values. Returns (0, 0) if the surface is not configured.

func (*Surface) Configure

func (s *Surface) Configure(device hal.Device, config *hal.SurfaceConfiguration) error

Configure configures the surface for presentation.

On Wayland, this creates a wl_egl_window via libwayland-egl.so and then an EGL window surface. On X11, eglCreateWindowSurface takes the raw X11 Window handle directly.

Returns hal.ErrZeroArea if width or height is zero. This commonly happens when the window is minimized or not yet fully visible. Wait until the window has valid dimensions before calling Configure again.

Returns hal.ErrSurfaceDeviceMismatch for a Device opened on another context than the surface's: GL objects are not shared between EGL contexts, and on Wayland the contexts may sit on different wl_displays, which libwayland would abort on ("proxy and queue point to different wl_displays").

func (*Surface) Destroy

func (s *Surface) Destroy()

Destroy releases the surface resources. Order: GL resources → EGL surface → wl_egl_window → the Surface's reference to its AdapterContext, the last of which destroys the context.

func (*Surface) DiscardTexture

func (s *Surface) DiscardTexture(_ hal.SurfaceTexture)

DiscardTexture discards a previously acquired texture.

func (*Surface) GetAdapterInfo

func (s *Surface) GetAdapterInfo() (adapter hal.ExposedAdapter, ok bool)

GetAdapterInfo returns adapter information from this surface's GL context. Probes GL version, extensions, features, limits, and MSAA support to build an accurate ExposedAdapter. Follows Rust wgpu-hal adapter.rs expose pattern. ok is false when the context is below OpenGL 3.3 / ES 3.0 (no adapter).

func (*Surface) Unconfigure

func (s *Surface) Unconfigure(_ hal.Device)

Unconfigure marks the surface as unconfigured and releases the EGL window surface and wl_egl_window (on Wayland).

type SurfaceTexture

type SurfaceTexture struct {
	// contains filtered or unexported fields
}

SurfaceTexture implements hal.SurfaceTexture for OpenGL. It represents the default framebuffer.

func (*SurfaceTexture) AddPendingRef added in v0.23.4

func (t *SurfaceTexture) AddPendingRef()

func (*SurfaceTexture) CurrentUsage added in v0.23.4

func (t *SurfaceTexture) CurrentUsage() gputypes.TextureUsage

CurrentUsage returns 0 — GLES surface textures have no state tracking.

func (*SurfaceTexture) DecPendingRef added in v0.23.4

func (t *SurfaceTexture) DecPendingRef()

func (*SurfaceTexture) Destroy

func (t *SurfaceTexture) Destroy()

Destroy is a no-op for surface textures.

func (*SurfaceTexture) NativeHandle added in v0.12.0

func (t *SurfaceTexture) NativeHandle() uintptr

NativeHandle returns 0 (OpenGL default framebuffer has no handle).

type Texture

type Texture struct {
	// contains filtered or unexported fields
}

Texture implements hal.Texture for OpenGL.

func (*Texture) AddPendingRef added in v0.23.4

func (t *Texture) AddPendingRef()

func (*Texture) CurrentUsage added in v0.23.4

func (t *Texture) CurrentUsage() gputypes.TextureUsage

CurrentUsage returns 0 — GLES has no explicit resource state tracking.

func (*Texture) DecPendingRef added in v0.23.4

func (t *Texture) DecPendingRef()

func (*Texture) Destroy

func (t *Texture) Destroy()

Destroy releases the texture and any associated framebuffer object.

func (*Texture) NativeHandle added in v0.12.0

func (t *Texture) NativeHandle() uintptr

NativeHandle returns the GL texture object ID.

type TextureDescriptor

type TextureDescriptor = hal.TextureDescriptor

Type aliases for hal descriptors

type TextureView

type TextureView struct {
	// contains filtered or unexported fields
}

TextureView implements hal.TextureView for OpenGL.

func (*TextureView) Destroy

func (v *TextureView) Destroy()

Destroy drops the view's handle; a GL texture view holds no GL object. It may be called more than once.

func (*TextureView) NativeHandle added in v0.12.0

func (v *TextureView) NativeHandle() uintptr

NativeHandle returns the view's opaque per-device handle. A GL texture object has no view object, so a bind group needs the view itself (its mip level and layer, which a storage texture binds through glBindImageTexture); CreateBindGroup resolves the handle back through the device's table (newBindGroup). The handle is not the view's address: see package handletable.

type TextureViewDescriptor

type TextureViewDescriptor = hal.TextureViewDescriptor

Type aliases for hal descriptors

type TimestampQueryCommand added in v0.28.4

type TimestampQueryCommand struct {
	// contains filtered or unexported fields
}

TimestampQueryCommand records a timestamp via glQueryCounter. Used internally by render/compute pass timestamp writes. Matches Rust wgpu-hal/src/gles/queue.rs TimestampQuery command.

func (*TimestampQueryCommand) Execute added in v0.28.4

func (c *TimestampQueryCommand) Execute(ctx *gl.Context)

type UnsupportedTextureFormatError

type UnsupportedTextureFormatError struct {
	Format gputypes.TextureFormat
}

UnsupportedTextureFormatError reports a texture format the GLES backend has no GL storage for.

func (*UnsupportedTextureFormatError) Error

type UseProgramCommand

type UseProgramCommand struct {
	// contains filtered or unexported fields
}

UseProgramCommand activates a shader program.

func (*UseProgramCommand) Execute

func (c *UseProgramCommand) Execute(ctx *gl.Context)

Directories

Path Synopsis
Package egl provides EGL context management for OpenGL ES on Linux.
Package egl provides EGL context management for OpenGL ES on Linux.
Package gl provides OpenGL constants and types for the GLES backend.
Package gl provides OpenGL constants and types for the GLES backend.
Package wgl provides Windows OpenGL (WGL) context management.
Package wgl provides Windows OpenGL (WGL) context management.

Jump to

Keyboard shortcuts

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