Documentation
¶
Overview ¶
Package sdlgpu is the SDL3 GPU backend for MeUI. It creates a native GPU device through SDL (Vulkan, Metal or D3D12) and presents frames through a claimed window.
This is deliberately a separate module from meui-render-gl: it does not use OpenGL or EGL, and it selects its shaders from the generated artifacts in meui-shaders.
Index ¶
- type Buffer
- type Device
- func (d *Device) Claim(window unsafe.Pointer) error
- func (d *Device) Clear(window unsafe.Pointer, c FColor) error
- func (d *Device) Close()
- func (d *Device) CreateNearestSampler() (*Sampler, error)
- func (d *Device) CreatePipeline(vs, fs *Shader, window unsafe.Pointer) (*Pipeline, error)
- func (d *Device) CreateRectPipeline(vs, fs *Shader, window unsafe.Pointer) (*Pipeline, error)
- func (d *Device) CreateSDFPipeline(vs, fs *Shader, window unsafe.Pointer) (*Pipeline, error)
- func (d *Device) CreateShader(stage int, format uint32, entry string, code []byte, uniformBuffers uint32) (*Shader, error)
- func (d *Device) CreateShaderWithSamplers(stage int, format uint32, entry string, code []byte, ...) (*Shader, error)
- func (d *Device) CreateTextPipeline(vs, fs *Shader, window unsafe.Pointer) (*Pipeline, error)
- func (d *Device) CreateTexture2D(w, h uint32) (*Texture, error)
- func (d *Device) CreateWindow(title string, w, h int32) unsafe.Pointer
- func (d *Device) DestroyWindow(win unsafe.Pointer)
- func (d *Device) DrawRect(window unsafe.Pointer, p *Pipeline, x, y, w, h float32, color [4]float32) error
- func (d *Device) DrawSDFRect(window unsafe.Pointer, p *Pipeline, radius, x, y, w, h float32, ...) error
- func (d *Device) DrawTextQuad(window unsafe.Pointer, p *Pipeline, tex *Texture, samp *Sampler, ...) error
- func (d *Device) DrawTriangle(window unsafe.Pointer, p *Pipeline, vb *Buffer, uniform []float32) error
- func (d *Device) Driver() string
- func (d *Device) NewBuffer(usage uint32, data []byte) (*Buffer, error)
- func (d *Device) ReleaseBuffer(b *Buffer)
- func (d *Device) ReleasePipeline(p *Pipeline)
- func (d *Device) ReleaseSampler(s *Sampler)
- func (d *Device) ReleaseShader(s *Shader)
- func (d *Device) ReleaseTexture(t *Texture)
- func (d *Device) ReleaseWindow(window unsafe.Pointer)
- type FColor
- type Pipeline
- type Sampler
- type Shader
- type Texture
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶ added in v0.1.2
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is a GPU vertex or uniform buffer.
type Device ¶
type Device struct {
// contains filtered or unexported fields
}
Device owns one SDL GPU device and the windows claimed for presentation.
func New ¶
New creates a GPU device, trying every shader format SDL can provide. SDL picks the native backend (Vulkan/Metal/D3D12) from the platform.
func (*Device) Clear ¶
Clear acquires a swapchain, clears it and submits. It is the smallest real frame and is used to validate the device/window path before the full batch renderer lands.
func (*Device) CreateNearestSampler ¶ added in v0.1.7
CreateNearestSampler creates a clamp-to-edge nearest sampler.
func (*Device) CreatePipeline ¶ added in v0.1.2
CreatePipeline builds a pipeline for the tri shader layout.
func (*Device) CreateRectPipeline ¶ added in v0.1.3
CreateRectPipeline builds a pipeline for rect.vert/frag: one float2 vertex.
func (*Device) CreateSDFPipeline ¶ added in v0.1.6
CreateSDFPipeline builds the 16-attribute SDF pipeline. It is paired with the simplified solid SDF fragment (no textures or clip loop).
func (*Device) CreateShader ¶ added in v0.1.1
func (d *Device) CreateShader(stage int, format uint32, entry string, code []byte, uniformBuffers uint32) (*Shader, error)
CreateShader uploads one stage. The caller owns the code slice for the call; SDL copies it into the backend shader object.
func (*Device) CreateShaderWithSamplers ¶ added in v0.1.7
func (d *Device) CreateShaderWithSamplers(stage int, format uint32, entry string, code []byte, samplers, uniformBuffers uint32) (*Shader, error)
CreateShaderWithSamplers is CreateShader with an explicit sampler count.
func (*Device) CreateTextPipeline ¶ added in v0.1.7
CreateTextPipeline builds the glyph atlas pipeline (5 vertex attributes).
func (*Device) CreateTexture2D ¶ added in v0.1.7
CreateTexture2D creates an uninitialised sampled 2D texture.
func (*Device) CreateWindow ¶
CreateWindow creates a plain SDL window for GPU presentation. Unlike meui-sdl's InitWindow it creates no OpenGL context.
func (*Device) DestroyWindow ¶
DestroyWindow destroys a window from CreateWindow.
func (*Device) DrawRect ¶ added in v0.1.3
func (d *Device) DrawRect(window unsafe.Pointer, p *Pipeline, x, y, w, h float32, color [4]float32) error
DrawRect presents a solid rectangle with the rect pipeline.
func (*Device) DrawSDFRect ¶ added in v0.1.6
func (d *Device) DrawSDFRect(window unsafe.Pointer, p *Pipeline, radius, x, y, w, h float32, color [4]float32) error
DrawSDFRect presents one solid rounded rectangle through the simplified SDF shader.
func (*Device) DrawTextQuad ¶ added in v0.1.7
func (d *Device) DrawTextQuad(window unsafe.Pointer, p *Pipeline, tex *Texture, samp *Sampler, x, y, w, h float32, color [4]float32) error
DrawTextQuad presents one textured quad through the text shader. With a dummy atlas this validates the sampler path; real glyph uploads come next.
func (*Device) DrawTriangle ¶ added in v0.1.2
func (d *Device) DrawTriangle(window unsafe.Pointer, p *Pipeline, vb *Buffer, uniform []float32) error
DrawTriangle presents a single triangle using the tri shader. It is the first end-to-end shader/pipeline/vertex/uniform draw.
func (*Device) NewBuffer ¶ added in v0.1.2
NewBuffer uploads bytes into a GPU buffer with the given usage flags.
func (*Device) ReleaseBuffer ¶ added in v0.1.2
Release destroys a buffer.
func (*Device) ReleasePipeline ¶ added in v0.1.2
Release destroys a pipeline.
func (*Device) ReleaseSampler ¶ added in v0.1.7
func (*Device) ReleaseShader ¶ added in v0.1.1
Release destroys a shader.
func (*Device) ReleaseTexture ¶ added in v0.1.7
func (*Device) ReleaseWindow ¶
ReleaseWindow releases a claimed window.
type Pipeline ¶ added in v0.1.2
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline is an SDL GPU graphics pipeline.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
sdlgpu-demo
command
Command sdlgpu-demo presents a moving rectangle through the SDL3 GPU backend.
|
Command sdlgpu-demo presents a moving rectangle through the SDL3 GPU backend. |