d3d11

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Rendered for windows/amd64

Overview

Package d3d11 draws scenes with Direct3D 11 into a window through a DXGI flip model swap chain, called through syscall like the rest of the Windows backend (no cgo). Every op of a scene is an instanced quad drawn by one shader (shader.hlsl, compiled ahead of time into shaders.go); clips are scissor rectangles, with the innermost rounded clip computed in the shader. The swap chain is the window's, opaque, or with NewComposed shown on it through DirectComposition, with its alpha.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileEffect

func CompileEffect(src string) ([]byte, error)

CompileEffect compiles the pixel shader of an effect whose shader is src, with the compiler Windows has, as go generate does for code compiled ahead of time.

func EffectSource

func EffectSource(src string) string

EffectSource returns the source of an effect's pixel shader: shader.hlsl with EFFECT defined, the head of effect.hlsl, the effect's shader (see scene.Effect), and the tail, which draws its instances with it (effectps). Effects compile it ahead of time with CompileEffect.

func PrecompileEffect

func PrecompileEffect(src string)

PrecompileEffect starts compiling the pixel shader of an effect whose shader is src, which nothing compiled ahead of time, on a goroutine of its own: the renderers then draw it with that code, waiting for the compilation if it has not finished, rather than each compiling it on its first draw. The code is kept on disk too, for the next launches. Package ui/shader calls it as it compiles a shader, which links the cache into apps that draw shaders only.

func RenderOffscreen

func RenderOffscreen(s *scene.Scene) ([]byte, int, error)

RenderOffscreen draws s with a renderer of its own into a window that never shows, and returns the premultiplied BGRA rows of its back buffer and their stride: for tests, as packages drawing effects have.

Types

type Renderer

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

Renderer draws scenes into a window.

func New

func New(hwnd uintptr) (*Renderer, error)

New creates a renderer drawing into the window hwnd, on the GPU or, when there is none, with Windows' software rasterizer (WARP). Its frames are opaque: what they leave transparent shows black.

func NewComposed

func NewComposed(hwnd uintptr) (*Renderer, error)

NewComposed creates a renderer whose frames show on the window hwnd through DirectComposition, premultiplied by their alpha, over what is behind the window's content: in a window without a redirection bitmap (WS_EX_NOREDIRECTIONBITMAP), its system backdrop, as Mica.

func (*Renderer) Composed

func (r *Renderer) Composed() bool

Composed reports whether the frames show through DirectComposition, with their alpha (NewComposed).

func (*Renderer) FrameInfo

func (r *Renderer) FrameInfo() string

FrameInfo describes the last frame for GOLET_FRAME_STATS.

func (*Renderer) Ready

func (r *Renderer) Ready(wake func()) bool

Ready reports whether a frame following the last one can draw at once, as none waits to present (latency.go); otherwise wake runs, on the main thread, once it has.

func (*Renderer) Release

func (r *Renderer) Release()

Release frees the renderer's GPU objects.

func (*Renderer) Render

func (r *Renderer) Render(s *scene.Scene) error

Render draws s into the window and presents it.

func (*Renderer) SetPost

func (r *Renderer) SetPost(post func(func()))

SetPost gives the renderer post, which runs a function on the main thread from any goroutine: a frame drawn while the screen has no room for it presents once it has, through post, rather than block in Present. Without it, frames block.

func (*Renderer) Software

func (r *Renderer) Software() bool

Software reports whether the renderer draws with WARP, on the CPU, for want of a GPU.

Directories

Path Synopsis
Package device creates Direct3D 11 devices: the device of package d3d11's renderer, and that of the Windows backend, which shows the controls of windows with a material through DirectComposition without the renderer.
Package device creates Direct3D 11 devices: the device of package d3d11's renderer, and that of the Windows backend, which shows the controls of windows with a material through DirectComposition without the renderer.

Jump to

Keyboard shortcuts

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