Versions in this module Expand all Collapse all v1 v1.0.6 Apr 10, 2025 v1.0.5 Apr 10, 2025 v1.0.4 Apr 10, 2025 v1.0.3 Apr 10, 2025 v1.0.2 Apr 10, 2025 v1.0.1 Apr 10, 2025 v1.0.0 Apr 10, 2025 Changes in this version + const MaxTextureLayers + const PushGroup + const VertexGroup + var Debug = false + var DebugAdapter = false + var NumThreads = 0 + var RoleBindingTypes = map[VarRoles]wgpu.BufferBindingType + var RoleBufferUsages = map[VarRoles]wgpu.BufferUsage + var SelectAdapter = -1 + var ShaderStageFlags = map[ShaderTypes]wgpu.ShaderStage + var TextureFormatNames = map[wgpu.TextureFormat]string + var TextureFormatSizes = map[wgpu.TextureFormat]int + var TypeSizes = map[Types]int + var TypeToTextureFormat = map[Types]wgpu.TextureFormat + var TypeToVertexFormat = map[Types]wgpu.VertexFormat + var WebGPUSamplerModes = map[SamplerModes]wgpu.AddressMode + var WebGPUTopologies = map[Topologies]wgpu.PrimitiveTopology + func BufferMapAsyncError(status wgpu.BufferMapAsyncStatus) error + func BufferReadSync(device *Device, size int, buffer *wgpu.Buffer) error + func DefaultNumThreads() int + func GLFWCreateWindow(size image.Point, title string, resize *func(size image.Point)) (surface *wgpu.Surface, terminate func(), pollEvents func() bool, ...) + func ImageToRGBA(img image.Image) *image.RGBA + func ImgCompToUint8(val float32) uint8 + func IncludeFS(fsys fs.FS, fpath, code string) string + func Init() error — darwin/amd64, linux/amd64, windows/amd64 + func Instance() *wgpu.Instance + func MemSizeAlign(size, align int) int + func MemSizeAlignDown(size, align int) int + func NoDisplayGPU() (*GPU, *Device, error) + func NumWorkgroups1D(n, threads int) (nx, ny int) + func NumWorkgroups2D(n, x, y int) (nx, ny int) + func ReadToBytes[E any](vl *Value, dest []E) error + func ReleaseInstance() + func SRGBFromLinear(rl, gl, bl float32) (r, g, b float32) + func SRGBFromLinearComp(lin float32) float32 + func SRGBToLinear(r, g, b float32) (rl, gl, bl float32) + func SRGBToLinearComp(srgb float32) float32 + func SetDebug(debug bool) + func SetDynamicValueFrom[E any](vl *Value, idx int, from []E) error + func SetTextureSRGBFromLinear(img *image.RGBA) + func SetTextureSRGBToLinear(img *image.RGBA) + func SetValueFrom[E any](vl *Value, from []E) error + func Terminate() — darwin/amd64, linux/amd64, windows/amd64 + func TextureSRGBFromLinear(img *image.RGBA) *image.RGBA + func TextureSRGBToLinear(img *image.RGBA) *image.RGBA + func ValueReadSync(device *Device, values ...*Value) error + func VectorizeFunc(threads, n int, fun func(idx uint32)) + type BorderColors int32 + const BorderBlack + const BorderColorsN + const BorderTrans + const BorderWhite + func BorderColorsValues() []BorderColors + func (i *BorderColors) SetInt64(in int64) + func (i *BorderColors) SetString(s string) error + func (i *BorderColors) UnmarshalText(text []byte) error + func (i BorderColors) Desc() string + func (i BorderColors) Int64() int64 + func (i BorderColors) MarshalText() ([]byte, error) + func (i BorderColors) String() string + func (i BorderColors) Values() []enums.Enum + type ComputePipeline struct + func NewComputePipeline(name string, sy System) *ComputePipeline + func NewComputePipelineShaderFS(fsys fs.FS, fname string, sy *ComputeSystem) *ComputePipeline + func (pl *ComputePipeline) BindAllGroups(ce *wgpu.ComputePassEncoder) + func (pl *ComputePipeline) BindGroup(ce *wgpu.ComputePassEncoder, group int) + func (pl *ComputePipeline) BindPipeline(ce *wgpu.ComputePassEncoder) error + func (pl *ComputePipeline) Config(rebuild bool) error + func (pl *ComputePipeline) Dispatch(ce *wgpu.ComputePassEncoder, nx, ny, nz int) error + func (pl *ComputePipeline) Dispatch1D(ce *wgpu.ComputePassEncoder, n, threads int) error + func (pl *ComputePipeline) Release() + type ComputeSystem struct + CommandEncoder *wgpu.CommandEncoder + ComputeEncoder *wgpu.ComputePassEncoder + ComputePipelines map[string]*ComputePipeline + Name string + func NewComputeSystem(gp *GPU, name string) *ComputeSystem + func (sy *ComputeSystem) AddComputePipeline(name string) *ComputePipeline + func (sy *ComputeSystem) BeginComputePass() (*wgpu.ComputePassEncoder, error) + func (sy *ComputeSystem) Config() + func (sy *ComputeSystem) Device() *Device + func (sy *ComputeSystem) EndComputePass() error + func (sy *ComputeSystem) GPU() *GPU + func (sy *ComputeSystem) NewCommandEncoder() (*wgpu.CommandEncoder, error) + func (sy *ComputeSystem) Release() + func (sy *ComputeSystem) Render() *Render + func (sy *ComputeSystem) Vars() *Vars + func (sy *ComputeSystem) WaitDone() + type Device struct + Device *wgpu.Device + Queue *wgpu.Queue + func NewComputeDevice(gpu *GPU) (*Device, error) + func NewDevice(gpu *GPU) (*Device, error) + func (dv *Device) Release() + func (dv *Device) WaitDone() + func (dv *Device) WaitDoneFunc(fun func()) + type GPU struct + ComputeOnly bool + DeviceName string + GPU *wgpu.Adapter + Limits wgpu.SupportedLimits + MaxComputeWorkGroupCount1D int + Properties wgpu.AdapterInfo + func NewComputeGPU() *GPU + func NewGPU(sf *wgpu.Surface) *GPU + func (gp *GPU) NewDevice() (*Device, error) + func (gp *GPU) PropertiesString() string + func (gp *GPU) Release() + func (gp *GPU) SelectComputeGPU(gpus []*wgpu.Adapter) int + func (gp *GPU) SelectGraphicsGPU(gpus []*wgpu.Adapter) int + type GraphicsPipeline struct + AlphaBlend bool + Multisample wgpu.MultisampleState + Primitive wgpu.PrimitiveState + func NewGraphicsPipeline(name string, sy *GraphicsSystem) *GraphicsPipeline + func (pl *GraphicsPipeline) BindAllGroups(rp *wgpu.RenderPassEncoder) + func (pl *GraphicsPipeline) BindDrawIndexed(rp *wgpu.RenderPassEncoder) + func (pl *GraphicsPipeline) BindGroup(rp *wgpu.RenderPassEncoder, group int) + func (pl *GraphicsPipeline) BindPipeline(rp *wgpu.RenderPassEncoder) error + func (pl *GraphicsPipeline) BindVertex(rp *wgpu.RenderPassEncoder) + func (pl *GraphicsPipeline) Config(rebuild bool) error + func (pl *GraphicsPipeline) DrawIndexed(rp *wgpu.RenderPassEncoder) + func (pl *GraphicsPipeline) FragmentEntry() *ShaderEntry + func (pl *GraphicsPipeline) Release() + func (pl *GraphicsPipeline) SetAlphaBlend(alphaBlend bool) + func (pl *GraphicsPipeline) SetCullMode(mode wgpu.CullMode) *GraphicsPipeline + func (pl *GraphicsPipeline) SetFrontFace(face wgpu.FrontFace) *GraphicsPipeline + func (pl *GraphicsPipeline) SetGraphicsDefaults() *GraphicsPipeline + func (pl *GraphicsPipeline) SetLineWidth(lineWidth float32) + func (pl *GraphicsPipeline) SetTopology(topo Topologies, restartEnable bool) *GraphicsPipeline + func (pl *GraphicsPipeline) VertexEntry() *ShaderEntry + type GraphicsSystem struct + CommandEncoder *wgpu.CommandEncoder + GraphicsPipelines map[string]*GraphicsPipeline + Name string + Renderer Renderer + func NewGraphicsSystem(gp *GPU, name string, rd Renderer) *GraphicsSystem + func (sy *GraphicsSystem) AddGraphicsPipeline(name string) *GraphicsPipeline + func (sy *GraphicsSystem) BeginRenderPass() (*wgpu.RenderPassEncoder, error) + func (sy *GraphicsSystem) BeginRenderPassNoClear() (*wgpu.RenderPassEncoder, error) + func (sy *GraphicsSystem) Config() + func (sy *GraphicsSystem) Device() *Device + func (sy *GraphicsSystem) EndRenderPass(rp *wgpu.RenderPassEncoder) + func (sy *GraphicsSystem) GPU() *GPU + func (sy *GraphicsSystem) NewCommandEncoder() (*wgpu.CommandEncoder, error) + func (sy *GraphicsSystem) Release() + func (sy *GraphicsSystem) Render() *Render + func (sy *GraphicsSystem) SetAlphaBlend(alphaBlend bool) *GraphicsSystem + func (sy *GraphicsSystem) SetClearColor(c color.Color) *GraphicsSystem + func (sy *GraphicsSystem) SetClearDepthStencil(depth float32, stencil uint32) *GraphicsSystem + func (sy *GraphicsSystem) SetCullMode(mode wgpu.CullMode) *GraphicsSystem + func (sy *GraphicsSystem) SetFrontFace(face wgpu.FrontFace) *GraphicsSystem + func (sy *GraphicsSystem) SetGraphicsDefaults() *GraphicsSystem + func (sy *GraphicsSystem) SetLineWidth(lineWidth float32) *GraphicsSystem + func (sy *GraphicsSystem) SetSize(size image.Point) + func (sy *GraphicsSystem) SetTopology(topo Topologies, restartEnable bool) *GraphicsSystem + func (sy *GraphicsSystem) SubmitRender(rp *wgpu.RenderPassEncoder) error + func (sy *GraphicsSystem) Vars() *Vars + func (sy *GraphicsSystem) WaitDone() + type Pipeline struct + Entries map[string]*ShaderEntry + Name string + Shaders map[string]*Shader + System System + func (pl *Pipeline) AddEntry(sh *Shader, typ ShaderTypes, entry string) *ShaderEntry + func (pl *Pipeline) AddShader(name string) *Shader + func (pl *Pipeline) EntryByName(name string) *ShaderEntry + func (pl *Pipeline) EntryByType(typ ShaderTypes) *ShaderEntry + func (pl *Pipeline) ShaderByName(name string) *Shader + func (pl *Pipeline) Vars() *Vars + type Render struct + ClearColor color.Color + ClearDepth float32 + ClearStencil uint32 + Depth Texture + DepthFormat Types + Format TextureFormat + Grab Texture + HasMulti bool + Multi Texture + func (rd *Render) BeginRenderPass(cmd *wgpu.CommandEncoder, view *wgpu.TextureView) *wgpu.RenderPassEncoder + func (rd *Render) BeginRenderPassNoClear(cmd *wgpu.CommandEncoder, view *wgpu.TextureView) *wgpu.RenderPassEncoder + func (rd *Render) ClearRenderPass(view *wgpu.TextureView) *wgpu.RenderPassDescriptor + func (rd *Render) Config(dev *Device, imgFmt *TextureFormat, depthFmt Types) + func (rd *Render) ConfigGrab(dev *Device) + func (rd *Render) ConfigGrabDepth(dev *Device) + func (rd *Render) DepthTextureArray() ([]float32, error) + func (rd *Render) GrabDepthTexture(dev *Device, cmd *wgpu.CommandEncoder) error + func (rd *Render) LoadRenderPass(view *wgpu.TextureView) *wgpu.RenderPassDescriptor + func (rd *Render) Release() + func (rd *Render) SetDepthDescriptor(rpd *wgpu.RenderPassDescriptor) + func (rd *Render) SetSize(sz image.Point) + type RenderTexture struct + Format TextureFormat + Frames []*Texture + GPU *GPU + NFrames int + func NewRenderTexture(gp *GPU, dev *Device, size image.Point, samples int, depthFmt Types) *RenderTexture + func (rt *RenderTexture) ConfigFrames() + func (rt *RenderTexture) Defaults() + func (rt *RenderTexture) Device() *Device + func (rt *RenderTexture) GetCurrentTexture() (*wgpu.TextureView, error) + func (rt *RenderTexture) GrabDepthTexture(cmd *wgpu.CommandEncoder) + func (rt *RenderTexture) GrabTexture(cmd *wgpu.CommandEncoder, idx int) + func (rt *RenderTexture) Present() + func (rt *RenderTexture) Release() + func (rt *RenderTexture) ReleaseFrames() + func (rt *RenderTexture) Render() *Render + func (rt *RenderTexture) SetSize(size image.Point) + type Renderer interface + Device func() *Device + GetCurrentTexture func() (*wgpu.TextureView, error) + Present func() + Render func() *Render + SetSize func(size image.Point) + type Sampler struct + Border BorderColors + Name string + UMode SamplerModes + VMode SamplerModes + WMode SamplerModes + func (sm *Sampler) Config(dev *Device) error + func (sm *Sampler) Defaults() + func (sm *Sampler) Release() + type SamplerModes int32 + const ClampToEdge + const MirrorRepeat + const Repeat + const SamplerModesN + func SamplerModesValues() []SamplerModes + func (i *SamplerModes) SetInt64(in int64) + func (i *SamplerModes) SetString(s string) error + func (i *SamplerModes) UnmarshalText(text []byte) error + func (i SamplerModes) Desc() string + func (i SamplerModes) Int64() int64 + func (i SamplerModes) MarshalText() ([]byte, error) + func (i SamplerModes) String() string + func (i SamplerModes) Values() []enums.Enum + func (sm SamplerModes) Mode() wgpu.AddressMode + type Shader struct + Name string + func NewShader(name string, dev *Device) *Shader + func (sh *Shader) OpenCode(code string) error + func (sh *Shader) OpenFile(fname string) error + func (sh *Shader) OpenFileFS(fsys fs.FS, fname string) error + func (sh *Shader) Release() + type ShaderEntry struct + Entry string + Shader *Shader + Type ShaderTypes + func NewShaderEntry(sh *Shader, typ ShaderTypes, entry string) *ShaderEntry + type ShaderTypes int32 + const ComputeShader + const FragmentShader + const UnknownShader + const VertexShader + type Surface struct + Format TextureFormat + GPU *GPU + func NewSurface(gp *GPU, wsurf *wgpu.Surface, size image.Point, samples int, depthFmt Types) *Surface + func (sf *Surface) Config() + func (sf *Surface) Defaults() + func (sf *Surface) Device() *Device + func (sf *Surface) GetCurrentTexture() (*wgpu.TextureView, error) + func (sf *Surface) InitConfig() error + func (sf *Surface) Present() + func (sf *Surface) Reconfig() bool + func (sf *Surface) Release() + func (sf *Surface) Render() *Render + func (sf *Surface) SetSize(sz image.Point) + type System interface + Device func() *Device + GPU func() *GPU + Render func() *Render + Vars func() *Vars + type Texture struct + Format TextureFormat + Name string + ReadBufferDims TextureBufferDims + Sampler Sampler + func NewTexture(dev *Device) *Texture + func (tx *Texture) ConfigDepth(dev *Device, depthType Types, imgFmt *TextureFormat) error + func (tx *Texture) ConfigGoImage(sz image.Point, layers int) + func (tx *Texture) ConfigMulti(dev *Device, imgFmt *TextureFormat) error + func (tx *Texture) ConfigReadBuffer() error + func (tx *Texture) ConfigRenderTexture(dev *Device, imgFmt *TextureFormat) error + func (tx *Texture) CopyToReadBuffer(cmd *wgpu.CommandEncoder) error + func (tx *Texture) CreateTexture(usage wgpu.TextureUsage) error + func (tx *Texture) ReadData(data *[]byte, removePadding bool) error + func (tx *Texture) ReadDataMapped() ([]byte, error) + func (tx *Texture) ReadGoImage() (*image.NRGBA, error) + func (tx *Texture) Release() + func (tx *Texture) ReleaseTexture() + func (tx *Texture) ReleaseView() + func (tx *Texture) SetFromGoImage(img image.Image, layer int) error + func (tx *Texture) SetShared(ot *Texture) + func (tx *Texture) UnmapReadData() error + type TextureBufferDims struct + Height uint64 + PaddedRowSize uint64 + UnpaddedRowSize uint64 + Width uint64 + func NewTextureBufferDims(size image.Point) *TextureBufferDims + func (td *TextureBufferDims) HasNoPadding() bool + func (td *TextureBufferDims) PaddedSize() uint64 + func (td *TextureBufferDims) Set(size image.Point) + func (td *TextureBufferDims) UnpaddedSize() uint64 + type TextureFormat struct + Format wgpu.TextureFormat + Layers int + Samples int + Size image.Point + func NewTextureFormat(width, height, layers int) *TextureFormat + func (im *TextureFormat) Aspect() float32 + func (im *TextureFormat) Bounds() image.Rectangle + func (im *TextureFormat) BytesPerPixel() int + func (im *TextureFormat) Defaults() + func (im *TextureFormat) Extent3D() wgpu.Extent3D + func (im *TextureFormat) IsRGBAUnorm() bool + func (im *TextureFormat) IsStdRGBA() bool + func (im *TextureFormat) LayerByteSize() int + func (im *TextureFormat) Set(w, h int, ft wgpu.TextureFormat) + func (im *TextureFormat) SetFormat(ft Types) + func (im *TextureFormat) SetMultisample(nsamp int) + func (im *TextureFormat) SetSize(w, h int) + func (im *TextureFormat) Size32() (width, height uint32) + func (im *TextureFormat) Stride() int + func (im *TextureFormat) String() string + func (im *TextureFormat) TotalByteSize() int + type Topologies int32 + const LineList + const LineStrip + const PointList + const TriangleList + const TriangleStrip + func (tp Topologies) Primitive() wgpu.PrimitiveTopology + type Types int32 + const Bool32 + const Depth24Stencil8 + const Depth32 + const Float32 + const Float32Matrix3 + const Float32Matrix4 + const Float32Vector2 + const Float32Vector3 + const Float32Vector4 + const Int16 + const Int32 + const Int32Vector2 + const Int32Vector4 + const Struct + const TextureBGRA32 + const TextureRGBA32 + const TypesN + const Uint16 + const Uint32 + const Uint32Vector2 + const Uint32Vector4 + const UndefinedType + func TypesValues() []Types + func (i *Types) SetInt64(in int64) + func (i *Types) SetString(s string) error + func (i *Types) UnmarshalText(text []byte) error + func (i Types) Desc() string + func (i Types) Int64() int64 + func (i Types) MarshalText() ([]byte, error) + func (i Types) String() string + func (i Types) Values() []enums.Enum + func (tp Types) Bytes() int + func (tp Types) IndexType() wgpu.IndexFormat + func (tp Types) TextureFormat() wgpu.TextureFormat + func (tp Types) VertexFormat() wgpu.VertexFormat + type Value struct + AlignVarSize int + AllocSize int + ArrayN int + DynamicIndex int + Index int + Name string + Texture *Texture + VarSize int + func NewValue(vr *Var, dev *Device, idx int) *Value + func (vl *Value) CreateBuffer() error + func (vl *Value) CreateReadBuffer() error + func (vl *Value) DynamicN() int + func (vl *Value) GPUToRead(cmd *wgpu.CommandEncoder) error + func (vl *Value) MemSize() int + func (vl *Value) NilBufferCheck() error + func (vl *Value) ReadSync() error + func (vl *Value) ReadToBytes(to []byte) error + func (vl *Value) Release() + func (vl *Value) ReleaseRead() + func (vl *Value) SetDynamicFromBytes(idx int, from []byte) error + func (vl *Value) SetDynamicIndex(idx int) *Value + func (vl *Value) SetDynamicN(n int) + func (vl *Value) SetFromBytes(from []byte) error + func (vl *Value) SetFromGoImage(img image.Image, layer int) *Texture + func (vl *Value) SetFromTexture(tx *Texture) *Texture + func (vl *Value) String() string + func (vl *Value) WriteDynamicBuffer() error + type ValueGroups map[string][]*Value + func (vg *ValueGroups) Add(name string, vals ...*Value) + func (vg ValueGroups) GPUToRead(name string, cmd *wgpu.CommandEncoder) error + func (vg ValueGroups) ReadSync(name string) error + func (vg ValueGroups) ValuesByName(name string) ([]*Value, error) + type Values struct + NameMap map[string]*Value + Values []*Value + func (vs *Values) Add(vr *Var, dev *Device, name ...string) *Value + func (vs *Values) CurrentValue() *Value + func (vs *Values) MemSize() int + func (vs *Values) Release() + func (vs *Values) SetCurrentValue(idx int) (*Value, error) + func (vs *Values) SetDynamicIndex(idx int) *Value + func (vs *Values) SetN(vr *Var, dev *Device, nvals int) bool + func (vs *Values) SetName(idx int, name string) (*Value, error) + func (vs *Values) ValueByIndex(idx int) (*Value, error) + func (vs *Values) ValueByName(name string) (*Value, error) + type Var struct + ArrayN int + Binding int + DynamicOffset bool + Group int + Name string + ReadOnly bool + Role VarRoles + SizeOf int + Type Types + Values Values + VarGroup *VarGroup + VertexInstance bool + func NewVar(vg *VarGroup, name string, typ Types, arrayN int, shaders ...ShaderTypes) *Var + func (vr *Var) MemSize() int + func (vr *Var) Release() + func (vr *Var) SetCurrentValue(i int) + func (vr *Var) SetNValues(dev *Device, nvals int) bool + func (vr *Var) String() string + type VarGroup struct + Group int + Name string + Role VarRoles + RoleMap map[VarRoles][]*Var + VarMap map[string]*Var + Vars []*Var + func (vg *VarGroup) Add(name string, typ Types, arrayN int, shaders ...ShaderTypes) *Var + func (vg *VarGroup) AddStruct(name string, size int, arrayN int, shaders ...ShaderTypes) *Var + func (vg *VarGroup) Config(dev *Device) error + func (vg *VarGroup) IndexVar() *Var + func (vg *VarGroup) Release() + func (vg *VarGroup) SetAllCurrentValue(i int) + func (vg *VarGroup) SetCurrentValue(name string, valueIndex int) (*Var, error) + func (vg *VarGroup) SetDynamicIndex(name string, dynamicIndex int) (*Var, error) + func (vg *VarGroup) SetNValues(nvals int) + func (vg *VarGroup) ValueByIndex(varName string, valIndex int) (*Value, error) + func (vg *VarGroup) ValueByName(varName, valName string) (*Value, error) + func (vg *VarGroup) VarByName(name string) (*Var, error) + type VarRoles int32 + const Index + const Push + const SampledTexture + const Storage + const StorageTexture + const UndefVarRole + const Uniform + const VarRolesN + const Vertex + func VarRolesValues() []VarRoles + func (i *VarRoles) SetInt64(in int64) + func (i *VarRoles) SetString(s string) error + func (i *VarRoles) UnmarshalText(text []byte) error + func (i VarRoles) Desc() string + func (i VarRoles) Int64() int64 + func (i VarRoles) MarshalText() ([]byte, error) + func (i VarRoles) String() string + func (i VarRoles) Values() []enums.Enum + func (vr VarRoles) BindingType() wgpu.BufferBindingType + func (vr VarRoles) BufferUsages() wgpu.BufferUsage + func (vr VarRoles) IsDynamic() bool + type Vars struct + Groups map[int]*VarGroup + RoleMap map[VarRoles][]*Var + func (vs *Vars) AddGroup(role VarRoles, name ...string) *VarGroup + func (vs *Vars) AddPushGroup() *VarGroup + func (vs *Vars) AddVertexGroup() *VarGroup + func (vs *Vars) Config(dev *Device) error + func (vs *Vars) Group(group int) (*VarGroup, error) + func (vs *Vars) NGroups() int + func (vs *Vars) PushGroup() *VarGroup + func (vs *Vars) Release() + func (vs *Vars) SetCurrentValue(group int, name string, valueIndex int) (*Var, error) + func (vs *Vars) SetDynamicIndex(group int, name string, dynamicIndex int) *Var + func (vs *Vars) StartGroup() int + func (vs *Vars) StringDoc() string + func (vs *Vars) ValueByIndex(group int, varName string, valIndex int) (*Value, error) + func (vs *Vars) ValueByName(group int, varName, valName string) (*Value, error) + func (vs *Vars) VarByName(group int, name string) (*Var, error) + func (vs *Vars) VertexGroup() *VarGroup + func (vs *Vars) VertexLayout() []wgpu.VertexBufferLayout