Documentation
¶
Overview ¶
Package gles implements the HAL backend for OpenGL ES 3.0 / OpenGL 3.3+.
This backend provides a Pure Go implementation using syscall directly, without any CGO or external dependencies.
Platform Support ¶
Currently supported:
- Windows (WGL) - via hal/gles/wgl package
Planned:
- Linux (GLX/EGL)
- macOS (CGL/EGL)
- Android (EGL)
- WebGL (via wasm)
Architecture ¶
The backend is organized into subpackages:
hal/gles/ ├── gl/ - OpenGL function bindings ├── wgl/ - Windows GL context management ├── glx/ - Linux X11 GL context (planned) ├── egl/ - EGL context for mobile/modern Linux (planned) └── cgl/ - macOS CGL context (planned)
Usage ¶
Import this package to register the OpenGL backend:
import _ "github.com/gogpu/wgpu/hal/gles"
The backend is then available via hal.GetBackend(types.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 ¶
- type Adapter
- type AttachDepthStencilCommand
- type Backend
- type BindFramebufferCommand
- type BindGroup
- type BindGroupDescriptor
- type BindGroupLayout
- type BindGroupLayoutDescriptor
- type BindGroupLayoutInfo
- type BindSurfaceFramebufferCommand
- type BindVAOCommand
- type Buffer
- type BufferDescriptor
- type ClearBufferCommand
- type ClearColorCommand
- type ClearDepthCommand
- type ClearStencilCommand
- type Command
- type CommandBuffer
- type CommandEncoder
- func (e *CommandEncoder) BeginComputePass(_ *hal.ComputePassDescriptor) hal.ComputePassEncoder
- func (e *CommandEncoder) BeginEncoding(label string) error
- func (e *CommandEncoder) BeginRenderPass(desc *hal.RenderPassDescriptor) hal.RenderPassEncoder
- func (e *CommandEncoder) ClearBuffer(buffer hal.Buffer, offset, size uint64)
- func (e *CommandEncoder) CopyBufferToBuffer(src, dst hal.Buffer, regions []hal.BufferCopy)
- func (e *CommandEncoder) CopyBufferToTexture(src hal.Buffer, dst hal.Texture, regions []hal.BufferTextureCopy)
- func (e *CommandEncoder) CopyTextureToBuffer(src hal.Texture, dst hal.Buffer, regions []hal.BufferTextureCopy)
- func (e *CommandEncoder) CopyTextureToTexture(src, dst hal.Texture, regions []hal.TextureCopy)
- func (e *CommandEncoder) Destroy()
- func (e *CommandEncoder) DiscardEncoding()
- func (e *CommandEncoder) EndEncoding() (hal.CommandBuffer, error)
- func (e *CommandEncoder) ResetAll(_ []hal.CommandBuffer)
- func (e *CommandEncoder) ResolveQuerySet(_ hal.QuerySet, _, _ uint32, _ hal.Buffer, _ uint64)
- func (e *CommandEncoder) TransitionBuffers(_ []hal.BufferBarrier)
- func (e *CommandEncoder) TransitionTextures(_ []hal.TextureBarrier)
- type CommandEncoderDescriptor
- type ComputePassEncoder
- func (e *ComputePassEncoder) Dispatch(x, y, z uint32)
- func (e *ComputePassEncoder) DispatchIndirect(buffer hal.Buffer, offset uint64)
- func (e *ComputePassEncoder) End()
- func (e *ComputePassEncoder) SetBindGroup(index uint32, group hal.BindGroup, offsets []uint32)
- func (e *ComputePassEncoder) SetPipeline(pipeline hal.ComputePipeline)
- type ComputePipeline
- type ComputePipelineDescriptor
- type CopyBufferCommand
- type CopyTextureToBufferCommand
- type Device
- func (d *Device) CreateBindGroup(desc *BindGroupDescriptor) (hal.BindGroup, error)
- func (d *Device) CreateBindGroupLayout(desc *BindGroupLayoutDescriptor) (hal.BindGroupLayout, error)
- func (d *Device) CreateBuffer(desc *BufferDescriptor) (hal.Buffer, error)
- func (d *Device) CreateCommandEncoder(_ *CommandEncoderDescriptor) (hal.CommandEncoder, error)
- func (d *Device) CreateComputePipeline(desc *ComputePipelineDescriptor) (hal.ComputePipeline, error)
- func (d *Device) CreateFence() (hal.Fence, error)
- func (d *Device) CreatePipelineLayout(desc *PipelineLayoutDescriptor) (hal.PipelineLayout, error)
- func (d *Device) CreateQuerySet(_ *hal.QuerySetDescriptor) (hal.QuerySet, error)
- func (d *Device) CreateRenderBundleEncoder(desc *hal.RenderBundleEncoderDescriptor) (hal.RenderBundleEncoder, error)
- func (d *Device) CreateRenderPipeline(desc *RenderPipelineDescriptor) (hal.RenderPipeline, error)
- func (d *Device) CreateSampler(desc *SamplerDescriptor) (hal.Sampler, error)
- func (d *Device) CreateShaderModule(desc *ShaderModuleDescriptor) (hal.ShaderModule, error)
- func (d *Device) CreateTexture(desc *TextureDescriptor) (hal.Texture, error)
- func (d *Device) CreateTextureView(texture hal.Texture, desc *TextureViewDescriptor) (hal.TextureView, error)
- func (d *Device) Destroy()
- func (d *Device) DestroyBindGroup(group hal.BindGroup)
- func (d *Device) DestroyBindGroupLayout(layout hal.BindGroupLayout)
- func (d *Device) DestroyBuffer(buffer hal.Buffer)
- func (d *Device) DestroyComputePipeline(pipeline hal.ComputePipeline)
- func (d *Device) DestroyFence(fence hal.Fence)
- func (d *Device) DestroyPipelineLayout(layout hal.PipelineLayout)
- func (d *Device) DestroyQuerySet(_ hal.QuerySet)
- func (d *Device) DestroyRenderBundle(bundle hal.RenderBundle)
- func (d *Device) DestroyRenderPipeline(pipeline hal.RenderPipeline)
- func (d *Device) DestroySampler(sampler hal.Sampler)
- func (d *Device) DestroyShaderModule(module hal.ShaderModule)
- func (d *Device) DestroyTexture(texture hal.Texture)
- func (d *Device) DestroyTextureView(view hal.TextureView)
- func (d *Device) FreeCommandBuffer(cmdBuffer hal.CommandBuffer)
- func (d *Device) GetFenceStatus(fence hal.Fence) (bool, error)
- func (d *Device) MapBuffer(buffer hal.Buffer, offset, size uint64) (hal.BufferMapping, error)
- func (d *Device) ResetFence(fence hal.Fence) error
- func (d *Device) UnmapBuffer(buffer hal.Buffer) error
- func (d *Device) Wait(fence hal.Fence, value uint64, timeout time.Duration) (bool, error)
- func (d *Device) WaitIdle() error
- type DispatchCommand
- type DispatchIndirectCommand
- type DrawCommand
- type DrawIndexedCommand
- type EnsureOffscreenFBOCommand
- type Fence
- type Instance
- type MSAAResolveCommand
- type PipelineLayout
- type PipelineLayoutDescriptor
- type Queue
- func (q *Queue) GetTimestampPeriod() float32
- func (q *Queue) PollCompleted() uint64
- func (q *Queue) Present(surface hal.Surface, _ hal.SurfaceTexture, damageRects []image.Rectangle) error
- func (q *Queue) Submit(commandBuffers []hal.CommandBuffer) (uint64, error)
- func (q *Queue) SupportsCommandBufferCopies() bool
- func (q *Queue) WriteBuffer(buffer hal.Buffer, offset uint64, data []byte) error
- func (q *Queue) WriteTexture(dst *hal.ImageCopyTexture, data []byte, layout *hal.ImageDataLayout, ...) error
- type RenderPassEncoder
- func (e *RenderPassEncoder) Draw(vertexCount, instanceCount, firstVertex, firstInstance uint32)
- func (e *RenderPassEncoder) DrawIndexed(indexCount, instanceCount, firstIndex uint32, baseVertex int32, ...)
- func (e *RenderPassEncoder) DrawIndexedIndirect(buffer hal.Buffer, offset uint64)
- func (e *RenderPassEncoder) DrawIndirect(buffer hal.Buffer, offset uint64)
- func (e *RenderPassEncoder) End()
- func (e *RenderPassEncoder) ExecuteBundle(bundle hal.RenderBundle)
- func (e *RenderPassEncoder) SetBindGroup(index uint32, group hal.BindGroup, offsets []uint32)
- func (e *RenderPassEncoder) SetBlendConstant(color *gputypes.Color)
- func (e *RenderPassEncoder) SetIndexBuffer(buffer hal.Buffer, format gputypes.IndexFormat, offset uint64)
- func (e *RenderPassEncoder) SetPipeline(pipeline hal.RenderPipeline)
- func (e *RenderPassEncoder) SetScissorRect(x, y, width, height uint32)
- func (e *RenderPassEncoder) SetStencilReference(ref uint32)
- func (e *RenderPassEncoder) SetVertexBuffer(slot uint32, buffer hal.Buffer, offset uint64)
- func (e *RenderPassEncoder) SetViewport(x, y, width, height, minDepth, maxDepth float32)
- type RenderPipeline
- type RenderPipelineDescriptor
- type Sampler
- type SamplerDescriptor
- type SetBindGroupCommand
- type SetBlendConstantCommand
- type SetIndexBufferCommand
- type SetPipelineStateCommand
- type SetScissorCommand
- type SetStencilRefCommand
- type SetVertexBufferCommand
- type SetViewportCommand
- type ShaderModule
- type ShaderModuleDescriptor
- type Surface
- func (s *Surface) AcquireTexture(_ hal.Fence) (*hal.AcquiredSurfaceTexture, error)
- func (s *Surface) Configure(_ hal.Device, config *hal.SurfaceConfiguration) error
- func (s *Surface) Destroy()
- func (s *Surface) DiscardTexture(_ hal.SurfaceTexture)
- func (s *Surface) GetAdapterInfo() hal.ExposedAdapter
- func (s *Surface) Unconfigure(_ hal.Device)
- type SurfaceTexture
- type Texture
- type TextureDescriptor
- type TextureView
- type TextureViewDescriptor
- type UseProgramCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements hal.Adapter for OpenGL on Linux.
func (*Adapter) SurfaceCapabilities ¶
func (a *Adapter) SurfaceCapabilities(_ hal.Surface) *hal.SurfaceCapabilities
SurfaceCapabilities returns surface capabilities.
func (*Adapter) TextureFormatCapabilities ¶
func (a *Adapter) TextureFormatCapabilities(format gputypes.TextureFormat) hal.TextureFormatCapabilities
TextureFormatCapabilities returns capabilities for a texture format.
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.
func (*AttachDepthStencilCommand) Execute ¶ added in v0.16.0
func (c *AttachDepthStencilCommand) Execute(ctx *gl.Context)
type Backend ¶
type Backend struct{}
Backend implements hal.Backend for OpenGL ES / OpenGL 3.3+ on Linux.
func (Backend) CreateInstance ¶
CreateInstance creates a new OpenGL instance.
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.
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 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) NativeHandle ¶ added in v0.12.0
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 ClearColorCommand ¶
type ClearColorCommand struct {
// contains filtered or unexported fields
}
ClearColorCommand clears a color attachment.
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 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(_ *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) ClearBuffer ¶
func (e *CommandEncoder) ClearBuffer(buffer hal.Buffer, offset, size uint64)
ClearBuffer clears a buffer region to zero.
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. Note: Requires glTexSubImage2D with pixel unpack buffer binding. Currently a no-op stub - texture uploads should use Queue.WriteTexture.
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. Note: Requires glCopyImageSubData (GL 4.3+ / GLES 3.2+). For older GL versions, requires framebuffer blit workaround.
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) ResetAll ¶
func (e *CommandEncoder) ResetAll(_ []hal.CommandBuffer)
ResetAll resets command buffers for reuse.
func (*CommandEncoder) ResolveQuerySet ¶ added in v0.16.4
ResolveQuerySet copies query results from a query set into a destination buffer. TODO: implement using GL_EXT_disjoint_timer_query when query sets are supported.
func (*CommandEncoder) TransitionBuffers ¶
func (e *CommandEncoder) TransitionBuffers(_ []hal.BufferBarrier)
TransitionBuffers transitions buffer states.
func (*CommandEncoder) TransitionTextures ¶
func (e *CommandEncoder) TransitionTextures(_ []hal.TextureBarrier)
TransitionTextures transitions texture states.
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) 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 between buffers.
func (*CopyBufferCommand) Execute ¶
func (c *CopyBufferCommand) 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 Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device implements hal.Device for OpenGL on Linux.
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.
func (*Device) CreateComputePipeline ¶
func (d *Device) CreateComputePipeline(desc *ComputePipelineDescriptor) (hal.ComputePipeline, error)
CreateComputePipeline creates a compute pipeline.
func (*Device) CreateFence ¶
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
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) DestroyBindGroup ¶
DestroyBindGroup destroys a bind group.
func (*Device) DestroyBindGroupLayout ¶
func (d *Device) DestroyBindGroupLayout(layout hal.BindGroupLayout)
DestroyBindGroupLayout destroys a bind group layout.
func (*Device) DestroyBuffer ¶
DestroyBuffer destroys a GPU buffer.
func (*Device) DestroyComputePipeline ¶
func (d *Device) DestroyComputePipeline(pipeline hal.ComputePipeline)
DestroyComputePipeline destroys a compute pipeline.
func (*Device) DestroyFence ¶
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
DestroyQuerySet destroys a query set.
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 ¶
DestroySampler destroys a sampler.
func (*Device) DestroyShaderModule ¶
func (d *Device) DestroyShaderModule(module hal.ShaderModule)
DestroyShaderModule destroys a shader module.
func (*Device) DestroyTexture ¶
DestroyTexture destroys a GPU texture.
func (*Device) DestroyTextureView ¶
func (d *Device) DestroyTextureView(view hal.TextureView)
DestroyTextureView destroys a texture view.
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) GetFenceStatus ¶ added in v0.13.0
GetFenceStatus returns true if the fence is signaled (non-blocking).
func (*Device) MapBuffer ¶ added in v0.25.0
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
ResetFence resets a fence to the unsignaled state.
func (*Device) UnmapBuffer ¶ added in v0.25.0
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.
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.
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.
func (*DrawIndexedCommand) Execute ¶
func (c *DrawIndexedCommand) 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 and binds it. If the texture already has an FBO, it simply binds it.
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.
type Instance ¶
type Instance struct{}
Instance implements hal.Instance for the OpenGL backend on Linux.
func (*Instance) CreateSurface ¶
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*.
func (*Instance) EnumerateAdapters ¶
func (i *Instance) EnumerateAdapters(surfaceHint hal.Surface) []hal.ExposedAdapter
EnumerateAdapters returns available OpenGL adapters. For OpenGL, there's typically one adapter per display.
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 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 Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue implements hal.Queue for OpenGL on Linux.
func (*Queue) GetTimestampPeriod ¶
GetTimestampPeriod returns the timestamp period in nanoseconds.
func (*Queue) PollCompleted ¶ added in v0.23.0
PollCompleted returns the highest submission index known to be completed. GLES is synchronous — after Flush, all submitted work is complete.
func (*Queue) Present ¶
func (q *Queue) Present(surface hal.Surface, _ hal.SurfaceTexture, damageRects []image.Rectangle) error
Present presents a surface texture to the screen.
Before SwapBuffers, blits the Surface's swapchain offscreen FBO to the default framebuffer (FBO 0) with an explicit Y-flip. User render passes render upside-down into the swapchain FBO (driven by naga's in-shader Y-flip); the blit un-flips for presentation. Mirrors Rust wgpu-hal src/gles/egl.rs Surface::present (1280-1308).
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) Submit ¶
func (q *Queue) Submit(commandBuffers []hal.CommandBuffer) (uint64, error)
Submit submits command buffers to the GPU. GLES is synchronous, so the submission is effectively complete immediately after Flush.
func (*Queue) SupportsCommandBufferCopies ¶ added in v0.23.4
SupportsCommandBufferCopies returns false for GLES on Linux. GLES uses direct GL calls for writes, not command buffer copy operations.
func (*Queue) WriteBuffer ¶
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(vertexCount, instanceCount, firstVertex, firstInstance uint32)
Draw draws primitives.
func (*RenderPassEncoder) DrawIndexed ¶
func (e *RenderPassEncoder) DrawIndexed(indexCount, instanceCount, firstIndex uint32, baseVertex int32, firstInstance uint32)
DrawIndexed draws indexed primitives.
func (*RenderPassEncoder) DrawIndexedIndirect ¶
func (e *RenderPassEncoder) DrawIndexedIndirect(buffer hal.Buffer, offset uint64)
DrawIndexedIndirect draws indexed primitives with GPU-generated parameters. Note: Requires GL_ARB_draw_indirect (GL 4.0+ / GLES 3.1+). Currently not implemented - use direct DrawIndexed calls instead.
func (*RenderPassEncoder) DrawIndirect ¶
func (e *RenderPassEncoder) DrawIndirect(buffer hal.Buffer, offset uint64)
DrawIndirect draws primitives with GPU-generated parameters. Note: Requires GL_ARB_draw_indirect (GL 4.0+ / GLES 3.1+). Currently not implemented - use direct Draw calls instead.
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(x, y, width, height uint32)
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 sets a vertex buffer and configures vertex attributes. In OpenGL, vertex attribute configuration (glVertexAttribPointer + glEnableVertexAttribArray) must be done explicitly. The layout is taken from the currently bound render pipeline's vertex buffer descriptors.
func (*RenderPassEncoder) SetViewport ¶
func (e *RenderPassEncoder) SetViewport(x, y, width, height, minDepth, maxDepth float32)
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 Sampler ¶
type Sampler struct {
// contains filtered or unexported fields
}
Sampler implements hal.Sampler for OpenGL using GL sampler objects (GL 3.3+).
func (*Sampler) NativeHandle ¶ added in v0.12.0
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 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.
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.
func (*Surface) AcquireTexture ¶
AcquireTexture returns the next surface texture for rendering.
func (*Surface) Configure ¶
Configure configures the surface for presentation.
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.
func (*Surface) DiscardTexture ¶
func (s *Surface) DiscardTexture(_ hal.SurfaceTexture)
DiscardTexture discards a previously acquired texture.
func (*Surface) GetAdapterInfo ¶
func (s *Surface) GetAdapterInfo() hal.ExposedAdapter
GetAdapterInfo returns adapter information from this surface's GL context.
func (*Surface) Unconfigure ¶
Unconfigure marks the surface as unconfigured.
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
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 is a no-op for texture views in OpenGL.
func (*TextureView) NativeHandle ¶ added in v0.12.0
func (v *TextureView) NativeHandle() uintptr
NativeHandle returns the underlying texture's GL object ID.
type TextureViewDescriptor ¶
type TextureViewDescriptor = hal.TextureViewDescriptor
Type aliases for hal descriptors
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)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package egl provides EGL (EGL) context management for OpenGL ES on Linux.
|
Package egl provides EGL (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. |