Documentation ¶
Index ¶
- Constants
- Variables
- func AllocBuffMem(gp *GPU, dev vk.Device, buffer vk.Buffer, props vk.MemoryPropertyFlagBits) vk.DeviceMemory
- func CheckErr(err *error)
- func CheckExisting(actual, required []string) (existing []string, missing int)
- func CmdBegin(cmd vk.CommandBuffer)
- func CmdBeginOneTime(cmd vk.CommandBuffer)
- func CmdEnd(cmd vk.CommandBuffer)
- func CmdReset(cmd vk.CommandBuffer)
- func CmdResetBegin(cmd vk.CommandBuffer)
- func CmdSubmit(cmd vk.CommandBuffer, dev *Device)
- func CmdSubmitWait(cmd vk.CommandBuffer, dev *Device)
- func CmdWait(dev *Device)
- func DestroyBuffer(dev vk.Device, buff *vk.Buffer)
- func DeviceExts(gpu vk.PhysicalDevice) (names []string, err error)
- func FindRequiredMemoryType(props vk.PhysicalDeviceMemoryProperties, ...) (uint32, bool)
- func FindRequiredMemoryTypeFallback(props vk.PhysicalDeviceMemoryProperties, ...) (uint32, bool)
- func FindString(str string, strs []string) int
- func FreeBuffMem(dev vk.Device, memory *vk.DeviceMemory)
- func IfPanic(err error, finalizers ...func())
- func ImageToRGBA(img image.Image) *image.RGBA
- func Init() error
- func InitNoDisplay() error
- func InstanceExts() (names []string, err error)
- func IsError(ret vk.Result) bool
- func MapMemory(dev vk.Device, mem vk.DeviceMemory, size int) unsafe.Pointer
- func MapMemoryAll(dev vk.Device, mem vk.DeviceMemory) unsafe.Pointer
- func MemSizeAlign(size, align int) int
- func NDescForTextures(nvals int) int
- func NewBuffer(dev vk.Device, size int, usage vk.BufferUsageFlagBits) vk.Buffer
- func NewError(ret vk.Result) error
- func NewFence(dev vk.Device) vk.Fence
- func NewSemaphore(dev vk.Device) vk.Semaphore
- func PlatformDefaults(gp *GPU)
- func SafeString(s string) string
- func SafeStrings(list []string) []string
- func SaveImage(path string, im image.Image) error
- func SliceUint32(data []byte) []uint32
- func Terminate()
- func ValidationLayers() (names []string, err error)
- type BorderColors
- type BuffTypes
- type CmdPool
- func (cp *CmdPool) BeginCmd() vk.CommandBuffer
- func (cp *CmdPool) BeginCmdOneTime() vk.CommandBuffer
- func (cp *CmdPool) ConfigResettable(dv *Device)
- func (cp *CmdPool) ConfigTransient(dv *Device)
- func (cp *CmdPool) Destroy(dev vk.Device)
- func (cp *CmdPool) EndCmd()
- func (cp *CmdPool) FreeBuffer(dev *Device)
- func (cp *CmdPool) NewBuffer(dv *Device) vk.CommandBuffer
- func (cp *CmdPool) Reset()
- func (cp *CmdPool) Submit(dev *Device)
- func (cp *CmdPool) SubmitWait(dev *Device)
- func (cp *CmdPool) SubmitWaitFree(dev *Device)
- type Device
- type Framebuffer
- func (fb *Framebuffer) Config()
- func (fb *Framebuffer) ConfigRender(rp *Render)
- func (fb *Framebuffer) ConfigRenderImage(gp *GPU, dev vk.Device, fmt ImageFormat)
- func (fb *Framebuffer) ConfigSurfaceImage(gp *GPU, dev vk.Device, fmt ImageFormat, img vk.Image)
- func (fb *Framebuffer) CopyToImage(toImg *Image, dev vk.Device, cmd vk.CommandBuffer)
- func (fb *Framebuffer) Destroy()
- func (fb *Framebuffer) DestroyFrame()
- func (fb *Framebuffer) GrabImage(dev vk.Device, cmd vk.CommandBuffer)
- type GPU
- func (gp *GPU) AddDeviceExt(ext ...string) bool
- func (gp *GPU) AddInstanceExt(ext ...string) bool
- func (gp *GPU) AddValidationLayer(ext string) bool
- func (gp *GPU) Config(name string) error
- func (gp *GPU) Defaults(graphics bool)
- func (gp *GPU) Destroy()
- func (gp *GPU) NewComputeSystem(name string) *System
- func (gp *GPU) NewGraphicsSystem(name string, dev *Device) *System
- func (gp *GPU) PropsString(print bool) string
- func (gp *GPU) SelectGPU(gpus []vk.PhysicalDevice, gpuCount int) int
- type HostImage
- type Image
- func (im *Image) AllocHost()
- func (im *Image) AllocImage()
- func (im *Image) ClearFlag(flag ...int)
- func (im *Image) ConfigDepth(gp *GPU, dev vk.Device, depthType Types, imgFmt *ImageFormat)
- func (im *Image) ConfigDepthView()
- func (im *Image) ConfigFramebuffer(gp *GPU, dev vk.Device, imgFmt *ImageFormat)
- func (im *Image) ConfigGoImage(sz image.Point, layers int)
- func (im *Image) ConfigMulti(gp *GPU, dev vk.Device, imgFmt *ImageFormat)
- func (im *Image) ConfigStdView()
- func (im *Image) ConfigValHost(buff *MemBuff, buffPtr unsafe.Pointer, offset int)
- func (im *Image) CopyImageRec() vk.ImageCopy
- func (im *Image) CopyRec() vk.BufferImageCopy
- func (im *Image) Destroy()
- func (im *Image) DestroyView()
- func (im *Image) DevGoImage() (*image.RGBA, error)
- func (im *Image) FreeHost()
- func (im *Image) FreeImage()
- func (im *Image) GoImage(layer int) (*image.RGBA, error)
- func (im *Image) HasFlag(flag ImageFlags) bool
- func (im *Image) HostPixels(layer int) []byte
- func (im *Image) IsActive() bool
- func (im *Image) IsHostActive() bool
- func (im *Image) IsHostOwner() bool
- func (im *Image) IsImageOwner() bool
- func (im *Image) IsVal() bool
- func (im *Image) SetFlag(flag ...int)
- func (im *Image) SetGoImage(img image.Image, layer int, flipY bool) error
- func (im *Image) SetNil()
- func (im *Image) SetSize(size image.Point) bool
- func (im *Image) SetVkImage(gp *GPU, dev vk.Device, img vk.Image)
- func (im *Image) Transition(cmd vk.CommandBuffer, format vk.Format, oldLayout, newLayout vk.ImageLayout, ...)
- func (im *Image) TransitionDstToGeneral(cmd vk.CommandBuffer)
- func (im *Image) TransitionDstToShader(cmd vk.CommandBuffer)
- func (im *Image) TransitionForDst(cmd vk.CommandBuffer, srcStage vk.PipelineStageFlagBits)
- type ImageFlags
- type ImageFormat
- func (im *ImageFormat) Aspect() float32
- func (im *ImageFormat) Bounds() image.Rectangle
- func (im *ImageFormat) BytesPerPixel() int
- func (im *ImageFormat) Defaults()
- func (im *ImageFormat) IsStdRGBA() bool
- func (im *ImageFormat) LayerByteSize() int
- func (im *ImageFormat) Set(w, h int, ft vk.Format)
- func (im *ImageFormat) SetFormat(ft Types)
- func (im *ImageFormat) SetMultisample(nsamp int)
- func (im *ImageFormat) SetSize(w, h int)
- func (im *ImageFormat) Size32() (width, height uint32)
- func (im *ImageFormat) Stride() int
- func (im *ImageFormat) String() string
- func (im *ImageFormat) TotalByteSize() int
- type MemBuff
- type MemReg
- type Memory
- func (mm *Memory) AllocBuffMem(buffer vk.Buffer, props vk.MemoryPropertyFlagBits) vk.DeviceMemory
- func (mm *Memory) AllocDev()
- func (mm *Memory) AllocDevBuff(bt BuffTypes)
- func (mm *Memory) AllocHost()
- func (mm *Memory) AllocHostBuff(bt BuffTypes)
- func (mm *Memory) Config(dev vk.Device)
- func (mm *Memory) Deactivate()
- func (mm *Memory) DeactivateBuff(bt BuffTypes)
- func (mm *Memory) Destroy(dev vk.Device)
- func (mm *Memory) Free() bool
- func (mm *Memory) FreeBuff(bt BuffTypes) bool
- func (mm *Memory) FreeBuffMem(memory *vk.DeviceMemory)
- func (mm *Memory) Init(gp *GPU, device *Device)
- func (mm *Memory) NewBuffer(size int, usage vk.BufferUsageFlagBits) vk.Buffer
- func (mm *Memory) SyncToGPU()
- func (mm *Memory) SyncToGPUBuff(bt BuffTypes)
- func (mm *Memory) SyncValFmGPU(vl *Val)
- func (mm *Memory) SyncValIdxFmGPU(set int, varNm string, valIdx int) error
- func (mm *Memory) SyncValNameFmGPU(set int, varNm, valNm string) error
- func (mm *Memory) SyncValsTextures(buff *MemBuff)
- func (mm *Memory) TransferAllValsTextures(buff *MemBuff)
- func (mm *Memory) TransferImagesFmGPU(buff vk.Buffer, imgs ...*Image)
- func (mm *Memory) TransferRegsFmGPU(buff *MemBuff, regs []MemReg)
- func (mm *Memory) TransferRegsToGPU(buff *MemBuff, regs []MemReg)
- func (mm *Memory) TransferTexturesToGPU(buff vk.Buffer, imgs ...*Image)
- func (mm *Memory) TransferToGPU()
- func (mm *Memory) TransferToGPUBuff(bt BuffTypes)
- type Pipeline
- func (pl *Pipeline) AddShader(name string, typ ShaderTypes) *Shader
- func (pl *Pipeline) AddShaderCode(name string, typ ShaderTypes, code []byte) *Shader
- func (pl *Pipeline) AddShaderFile(name string, typ ShaderTypes, fname string) *Shader
- func (pl *Pipeline) BindDrawVertex(cmd vk.CommandBuffer, descIdx int)
- func (pl *Pipeline) BindPipeline(cmd vk.CommandBuffer)
- func (pl *Pipeline) ComputeCommand(nx, ny, nz int)
- func (pl *Pipeline) Config()
- func (pl *Pipeline) ConfigCompute()
- func (pl *Pipeline) ConfigStages()
- func (pl *Pipeline) Destroy()
- func (pl *Pipeline) DestroyPipeline()
- func (pl *Pipeline) Draw(cmd vk.CommandBuffer, vtxCount, instanceCount, firstVtx, firstInstance int)
- func (pl *Pipeline) DrawVertex(cmd vk.CommandBuffer, descIdx int)
- func (pl *Pipeline) FreeShaders()
- func (pl *Pipeline) Init(sy *System)
- func (pl *Pipeline) InitPipeline()
- func (pl *Pipeline) Push(cmd vk.CommandBuffer, vr *Var, val unsafe.Pointer)
- func (pl *Pipeline) SetColorBlend(alphaBlend bool)
- func (pl *Pipeline) SetCullFace(back bool)
- func (pl *Pipeline) SetDynamicState()
- func (pl *Pipeline) SetFrontFace(ccw bool)
- func (pl *Pipeline) SetGraphicsDefaults()
- func (pl *Pipeline) SetLineWidth(lineWidth float32)
- func (pl *Pipeline) SetRasterization(polygonMode vk.PolygonMode, cullMode vk.CullModeFlagBits, ...)
- func (pl *Pipeline) SetTopology(topo Topologies, restartEnable bool)
- func (pl *Pipeline) ShaderByName(name string) *Shader
- func (pl *Pipeline) Vars() *Vars
- type Render
- func (rp *Render) BeginRenderPass(cmd vk.CommandBuffer, fr *Framebuffer)
- func (rp *Render) BeginRenderPassImpl(cmd vk.CommandBuffer, fr *Framebuffer, clear bool)
- func (rp *Render) BeginRenderPassNoClear(cmd vk.CommandBuffer, fr *Framebuffer)
- func (rp *Render) Config(dev vk.Device, imgFmt *ImageFormat, depthFmt Types, notSurface bool)
- func (rp *Render) ConfigGrab(dev vk.Device)
- func (rp *Render) ConfigImpl(dev vk.Device, imgFmt *ImageFormat, depthFmt Types, clear bool) vk.RenderPass
- func (rp *Render) Destroy()
- func (rp *Render) SetClearColor(r, g, b, a float32)
- func (rp *Render) SetClearDepthStencil(depth float32, stencil uint32)
- func (rp *Render) SetSize(size image.Point)
- type RenderFrame
- func (rf *RenderFrame) Config()
- func (rf *RenderFrame) Defaults()
- func (rf *RenderFrame) Destroy()
- func (rf *RenderFrame) Free()
- func (rf *RenderFrame) GrabImage(cmd vk.CommandBuffer, idx int)
- func (rf *RenderFrame) Init(gp *GPU, makeDevice bool) error
- func (rf *RenderFrame) ReConfig()
- func (rf *RenderFrame) ReConfigFrames()
- func (rf *RenderFrame) SetRender(rp *Render)
- func (rf *RenderFrame) SetSize(size image.Point) bool
- func (rf *RenderFrame) SubmitRender(cmd vk.CommandBuffer)
- func (rf *RenderFrame) WaitForRender()
- type Sampler
- type SamplerModes
- type Shader
- type ShaderTypes
- type StackFrame
- type Surface
- func (sf *Surface) AcquireNextImage() uint32
- func (sf *Surface) ConfigSwapchain()
- func (sf *Surface) Defaults()
- func (sf *Surface) Destroy()
- func (sf *Surface) FreeSwapchain()
- func (sf *Surface) Init(gp *GPU, vs vk.Surface) error
- func (sf *Surface) PresentImage(frameIdx uint32) error
- func (sf *Surface) ReConfigFrames()
- func (sf *Surface) ReConfigSwapchain()
- func (sf *Surface) SetRender(rp *Render)
- func (sf *Surface) SubmitRender(cmd vk.CommandBuffer)
- type System
- func (sy *System) AddPipeline(pl *Pipeline)
- func (sy *System) BeginRenderPass(cmd vk.CommandBuffer, fr *Framebuffer, descIdx int)
- func (sy *System) BeginRenderPassNoClear(cmd vk.CommandBuffer, fr *Framebuffer, descIdx int)
- func (sy *System) CmdBindTextureVarIdx(cmd vk.CommandBuffer, setIdx int, varNm string, valIdx int) (txIdx, descIdx int, switched bool, err error)
- func (sy *System) CmdBindVars(cmd vk.CommandBuffer, descIdx int)
- func (sy *System) CmdResetBindVars(cmd vk.CommandBuffer, descIdx int)
- func (sy *System) CmdSubmitWait()
- func (sy *System) ComputeBindVars(descIdx int)
- func (sy *System) ComputeResetBegin()
- func (sy *System) ComputeSubmit()
- func (sy *System) ComputeSubmitWait()
- func (sy *System) ComputeWait()
- func (sy *System) Config()
- func (sy *System) ConfigRender(imgFmt *ImageFormat, depthFmt Types)
- func (sy *System) ConfigRenderNonSurface(imgFmt *ImageFormat, depthFmt Types)
- func (sy *System) Destroy()
- func (sy *System) EndRenderPass(cmd vk.CommandBuffer)
- func (sy *System) InitCmd()
- func (sy *System) InitCompute(gp *GPU, name string) error
- func (sy *System) InitGraphics(gp *GPU, name string, dev *Device) error
- func (sy *System) MemCmdStart() vk.CommandBuffer
- func (sy *System) MemCmdSubmitWaitFree()
- func (sy *System) NewPipeline(name string) *Pipeline
- func (sy *System) ResetBeginRenderPass(cmd vk.CommandBuffer, fr *Framebuffer, descIdx int)
- func (sy *System) ResetBeginRenderPassNoClear(cmd vk.CommandBuffer, fr *Framebuffer, descIdx int)
- func (sy *System) SetClearColor(r, g, b, a float32)
- func (sy *System) SetClearDepthStencil(depth float32, stencil uint32)
- func (sy *System) SetColorBlend(alphaBlend bool)
- func (sy *System) SetCullFace(back bool)
- func (sy *System) SetFrontFace(ccw bool)
- func (sy *System) SetGraphicsDefaults()
- func (sy *System) SetLineWidth(lineWidth float32)
- func (sy *System) SetRasterization(polygonMode vk.PolygonMode, cullMode vk.CullModeFlagBits, ...)
- func (sy *System) SetTopology(topo Topologies, restartEnable bool)
- func (sy *System) Vars() *Vars
- type Texture
- type Topologies
- type Types
- type Val
- func (vl *Val) AllocHost(vr *Var, buff *MemBuff, buffPtr unsafe.Pointer, offset int) int
- func (vl *Val) Bytes() []byte
- func (vl *Val) ClearFlag(flag ...int)
- func (vl *Val) ClearMod()
- func (vl *Val) CopyFromBytes(srcPtr unsafe.Pointer)
- func (vl *Val) CopyToBytes(srcPtr unsafe.Pointer)
- func (vl *Val) Floats32() mat32.ArrayF32
- func (vl *Val) Free()
- func (vl *Val) HasFlag(flag ValFlags) bool
- func (vl *Val) Init(gp *GPU, vr *Var, idx int)
- func (vl *Val) IsMod() bool
- func (vl *Val) MemReg() MemReg
- func (vl *Val) MemSize(vr *Var) int
- func (vl *Val) PaddedArrayCheck() error
- func (vl *Val) SetFlag(flag ...int)
- func (vl *Val) SetGoImage(img image.Image, layer int, flipY bool) error
- func (vl *Val) SetMod()
- func (vl *Val) UInts32() mat32.ArrayU32
- type ValFlags
- type Vals
- func (vs *Vals) ActiveVals() []*Val
- func (vs *Vals) AllocHost(vr *Var, buff *MemBuff, offset int) int
- func (vs *Vals) AllocTexBySize(gp *GPU, vr *Var)
- func (vs *Vals) AllocTextures(mm *Memory)
- func (vs *Vals) ConfigVals(gp *GPU, dev vk.Device, vr *Var, nvals int) bool
- func (vs *Vals) Destroy()
- func (vs *Vals) Free()
- func (vs *Vals) MemSize(vr *Var, alignBytes int) int
- func (vs *Vals) ModRegs() []MemReg
- func (vs *Vals) SetGoImage(idx int, img image.Image, flipy bool)
- func (vs *Vals) SetName(idx int, name string) (*Val, error)
- func (vs *Vals) ValByIdxTry(idx int) (*Val, error)
- func (vs *Vals) ValByNameTry(name string) (*Val, error)
- type Var
- func (vr *Var) AllocHost(buff *MemBuff, offset int) int
- func (vr *Var) AllocTextures(mm *Memory)
- func (vr *Var) BindVal(descIdx int) (*Val, error)
- func (vr *Var) BuffType() BuffTypes
- func (vr *Var) Free()
- func (vr *Var) Init(name string, typ Types, arrayN int, role VarRoles, set int, ...)
- func (vr *Var) MemSize() int
- func (vr *Var) ModRegs() []MemReg
- func (vr *Var) SetTextureDev(dev vk.Device)
- func (vr *Var) String() string
- func (vr *Var) TextureValidIdx(stIdx, idx int) int
- func (vr *Var) ValsMemSize(alignBytes int) int
- type VarList
- type VarRoles
- type VarSet
- func (st *VarSet) Add(name string, typ Types, arrayN int, role VarRoles, shaders ...ShaderTypes) *Var
- func (st *VarSet) AddStruct(name string, size int, arrayN int, role VarRoles, shaders ...ShaderTypes) *Var
- func (st *VarSet) AddVar(vr *Var)
- func (st *VarSet) BindDynVal(vs *Vars, vr *Var, vl *Val) error
- func (st *VarSet) BindDynValIdx(vs *Vars, varNm string, valIdx int) error
- func (st *VarSet) BindDynValName(vs *Vars, varNm, valNm string) error
- func (st *VarSet) BindDynVar(vs *Vars, vr *Var) error
- func (st *VarSet) BindDynVarName(vs *Vars, varNm string) error
- func (st *VarSet) BindDynVars(vs *Vars)
- func (st *VarSet) BindStatVar(vs *Vars, vr *Var)
- func (st *VarSet) BindStatVarName(vs *Vars, varNm string) error
- func (st *VarSet) BindStatVars(vs *Vars)
- func (st *VarSet) Config(dev vk.Device) error
- func (st *VarSet) ConfigVals(nvals int)
- func (st *VarSet) DescLayout(dev vk.Device, vs *Vars)
- func (st *VarSet) Destroy(dev vk.Device)
- func (st *VarSet) DestroyLayout(dev vk.Device)
- func (st *VarSet) TexGpSzIdxs(vs *Vars, varNm string, valIdx int) *szalloc.Idxs
- func (vs *VarSet) VkPushConfig() []vk.PushConstantRange
- func (st *VarSet) VkVertexConfig() *vk.PipelineVertexInputStateCreateInfo
- type Vars
- func (vs *Vars) AddDynOff()
- func (vs *Vars) AddPushSet() *VarSet
- func (vs *Vars) AddSet() *VarSet
- func (vs *Vars) AddVertexSet() *VarSet
- func (vs *Vars) AllocHost(buff *MemBuff, offset int) int
- func (vs *Vars) AllocTextures(mm *Memory)
- func (vs *Vars) BindAllTextureVars(set int) error
- func (vs *Vars) BindDynVal(set int, vr *Var, vl *Val) error
- func (vs *Vars) BindDynValIdx(set int, varNm string, valIdx int) error
- func (vs *Vars) BindDynValName(set int, varNm, valNm string) error
- func (vs *Vars) BindDynVarName(set int, varNm string) error
- func (vs *Vars) BindDynVars(set int) error
- func (vs *Vars) BindDynVarsAll()
- func (vs *Vars) BindStatVarName(set int, varNm string) error
- func (vs *Vars) BindStatVars(set int) error
- func (vs *Vars) BindVarsEnd()
- func (vs *Vars) BindVarsStart(descIdx int)
- func (vs *Vars) BindVertexValIdx(varNm string, valIdx int) error
- func (vs *Vars) BindVertexValName(varNm, valNm string) error
- func (vs *Vars) Config() error
- func (vs *Vars) DescLayout(dev vk.Device)
- func (vs *Vars) Destroy(dev vk.Device)
- func (vs *Vars) Free(buff *MemBuff)
- func (vs *Vars) MemSize(buff *MemBuff) int
- func (vs *Vars) ModRegs(bt BuffTypes) []MemReg
- func (vs *Vars) NSets() int
- func (vs *Vars) PushSet() *VarSet
- func (vs *Vars) SetTry(set int) (*VarSet, error)
- func (vs *Vars) StartSet() int
- func (vs *Vars) StringDoc() string
- func (vs *Vars) TexGpSzIdxs(set int, varNm string, valIdx int) *szalloc.Idxs
- func (vs *Vars) ValByIdxTry(set int, varName string, valIdx int) (*Var, *Val, error)
- func (vs *Vars) ValByNameTry(set int, varName, valName string) (*Var, *Val, error)
- func (vs *Vars) VarByNameTry(set int, name string) (*Var, error)
- func (vs *Vars) VertexSet() *VarSet
- func (vs *Vars) VkPushConfig() []vk.PushConstantRange
- func (vs *Vars) VkVertexConfig() *vk.PipelineVertexInputStateCreateInfo
Constants ¶
const ( PointList = Topologies(vk.PrimitiveTopologyPointList) LineList = Topologies(vk.PrimitiveTopologyLineList) LineStrip = Topologies(vk.PrimitiveTopologyLineStrip) TriangleList = Topologies(vk.PrimitiveTopologyTriangleList) TriangleStrip = Topologies(vk.PrimitiveTopologyTriangleStrip) TriangleFan = Topologies(vk.PrimitiveTopologyTriangleFan) LineListWithAdjacency = Topologies(vk.PrimitiveTopologyLineListWithAdjacency) LineStripWithAdjacency = Topologies(vk.PrimitiveTopologyLineStripWithAdjacency) TriangleListWithAdjacency = Topologies(vk.PrimitiveTopologyTriangleListWithAdjacency) TriangleStripWithAdjacency = Topologies(vk.PrimitiveTopologyTriangleStripWithAdjacency) PatchList = Topologies(vk.PrimitiveTopologyPatchList) TopologiesN = PatchList + 1 )
const ( // FlipY used as named arg for flipping the Y axis of images, etc FlipY = true // NoFlipY uased as named arg for not flipping the Y axis of images NoFlipY = false )
const ( // CullBack is for SetCullFace function CullBack = true // CullFront is for SetCullFace function CullFront = false // CCW is for SetFrontFace function CCW = true // CW is for SetFrontFace function CW = false )
const ( // MaxTexturesPerSet is the maximum number of image variables that can be used // in one descriptor set. This value is a lowest common denominator across // platforms. To overcome this limitation, when more Texture vals are allocated, // multiple NDescs are used, setting the and switch // across those -- each such Desc set can hold this many textures. // NValsPer on a Texture var can be set higher and only this many will be // allocated in the descriptor set, with bindings of values wrapping // around across as many such sets as are vals, with a warning if insufficient // numbers are present. MaxTexturesPerSet = 16 // MaxImageLayers is the maximum number of layers per image MaxImageLayers = 128 )
const ( VertexSet = -2 PushSet = -1 )
const ( Version = "v1.0.9" GitCommit = "d9ef39f" // the commit JUST BEFORE the release VersionDate = "2023-01-10 07:35" // UTC )
Variables ¶
var BuffUsages = map[BuffTypes]vk.BufferUsageFlagBits{ VtxIdxBuff: vk.BufferUsageVertexBufferBit | vk.BufferUsageIndexBufferBit, UniformBuff: vk.BufferUsageUniformBufferBit | vk.BufferUsageUniformTexelBufferBit, StorageBuff: vk.BufferUsageStorageBufferBit | vk.BufferUsageStorageTexelBufferBit, TextureBuff: vk.BufferUsageStorageTexelBufferBit, }
BuffUsages maps BuffTypes into buffer usage flags
var Debug = false
Debug is a global flag for turning on debug mode Set to true prior to GPU.Config to get validation debugging.
var FormatSizes = map[vk.Format]int{ vk.FormatUndefined: 0, vk.FormatR16Sint: 2, vk.FormatR16Uint: 2, vk.FormatR32Sint: 4, vk.FormatR32g32Sint: 8, vk.FormatR32g32b32a32Sint: 16, vk.FormatR32Uint: 4, vk.FormatR32g32Uint: 8, vk.FormatR32g32b32a32Uint: 16, vk.FormatR32Sfloat: 4, vk.FormatR32g32Sfloat: 8, vk.FormatR32g32b32Sfloat: 12, vk.FormatR32g32b32a32Sfloat: 16, vk.FormatR64Sfloat: 8, vk.FormatR64g64Sfloat: 16, vk.FormatR64g64b64Sfloat: 24, vk.FormatR64g64b64a64Sfloat: 32, vk.FormatR8g8b8a8Srgb: 4, vk.FormatD32Sfloat: 4, vk.FormatD24UnormS8Uint: 4, }
FormatSizes gives size of known vulkan formats in bytes
var ImageFormatNames = map[vk.Format]string{ vk.FormatR8g8b8a8Srgb: "RGBA 8bit sRGB colorspace", vk.FormatR8g8b8a8Unorm: "RGBA 8bit unsigned linear colorspace", vk.FormatR5g6b5UnormPack16: "RGB 5bit (pack 16bit total) unsigned linear colorspace", vk.FormatA2b10g10r10UnormPack32: "ABGR 10bit, 2bit alpha (pack 32bit total), unsigned linear colorspace", vk.FormatB8g8r8a8Srgb: "BGRA 8bit sRGB colorspace", vk.FormatB8g8r8a8Unorm: "BGRA 8bit unsigned linear colorspace", vk.FormatR16g16b16a16Sfloat: "RGBA 16bit signed floating point linear colorspace", vk.FormatA2r10g10b10UnormPack32: "ARGB 10bit, 2bit alpha (pack 32bit total), unsigned linear colorspace", }
ImageFormatNames translates image format into human-readable string for most commonly-available formats
var KiT_BorderColors = kit.Enums.AddEnum(BorderColorsN, kit.NotBitFlag, nil)
var KiT_BuffTypes = kit.Enums.AddEnum(BuffTypesN, kit.NotBitFlag, nil)
var KiT_ImageFlags = kit.Enums.AddEnum(ImageFlagsN, kit.BitFlag, nil)
var KiT_SamplerModes = kit.Enums.AddEnum(SamplerModesN, kit.NotBitFlag, nil)
var KiT_Topologies = kit.Enums.AddEnum(TopologiesN, kit.NotBitFlag, nil)
var KiT_Types = kit.Enums.AddEnum(TypesN, kit.NotBitFlag, nil)
var KiT_VarRoles = kit.Enums.AddEnum(VarRolesN, kit.NotBitFlag, nil)
var RoleBuffers = map[VarRoles]BuffTypes{ UndefVarRole: StorageBuff, Vertex: VtxIdxBuff, Index: VtxIdxBuff, Uniform: UniformBuff, Storage: StorageBuff, UniformTexel: UniformBuff, StorageTexel: StorageBuff, StorageImage: StorageBuff, TextureRole: TextureBuff, }
RoleBuffers maps VarRoles onto type of memory buffer
var RoleDescriptors = map[VarRoles]vk.DescriptorType{ Uniform: vk.DescriptorTypeUniformBufferDynamic, Storage: vk.DescriptorTypeStorageBufferDynamic, UniformTexel: vk.DescriptorTypeUniformTexelBuffer, StorageTexel: vk.DescriptorTypeStorageTexelBuffer, StorageImage: vk.DescriptorTypeStorageImage, TextureRole: vk.DescriptorTypeCombinedImageSampler, }
var ShaderPipelineFlags = map[ShaderTypes]vk.PipelineStageFlagBits{ VertexShader: vk.PipelineStageVertexShaderBit, TessCtrlShader: vk.PipelineStageTessellationControlShaderBit, TessEvalShader: vk.PipelineStageTessellationEvaluationShaderBit, GeometryShader: vk.PipelineStageGeometryShaderBit, FragmentShader: vk.PipelineStageFragmentShaderBit, ComputeShader: vk.PipelineStageComputeShaderBit, }
var ShaderStageFlags = map[ShaderTypes]vk.ShaderStageFlagBits{ VertexShader: vk.ShaderStageVertexBit, TessCtrlShader: vk.ShaderStageTessellationControlBit, TessEvalShader: vk.ShaderStageTessellationEvaluationBit, GeometryShader: vk.ShaderStageGeometryBit, FragmentShader: vk.ShaderStageFragmentBit, ComputeShader: vk.ShaderStageComputeBit, AllShaders: vk.ShaderStageAll, }
var VulkanBorderColors = map[BorderColors]vk.BorderColor{ BorderTrans: vk.BorderColorIntTransparentBlack, BorderBlack: vk.BorderColorIntOpaqueBlack, BorderWhite: vk.BorderColorIntOpaqueWhite, }
var VulkanSamplerModes = map[SamplerModes]vk.SamplerAddressMode{ Repeat: vk.SamplerAddressModeRepeat, MirroredRepeat: vk.SamplerAddressModeMirroredRepeat, ClampToEdge: vk.SamplerAddressModeClampToEdge, ClampToBorder: vk.SamplerAddressModeClampToBorder, MirrorClampToEdge: vk.SamplerAddressModeMirrorClampToEdge, }
var VulkanTypes = map[Types]vk.Format{ UndefType: vk.FormatUndefined, Bool32: vk.FormatR32Uint, Int16: vk.FormatR16Sint, Uint16: vk.FormatR16Uint, Int32: vk.FormatR32Sint, Int32Vec2: vk.FormatR32g32Sint, Int32Vec4: vk.FormatR32g32b32a32Sint, Uint32: vk.FormatR32Uint, Uint32Vec2: vk.FormatR32g32Uint, Uint32Vec4: vk.FormatR32g32b32a32Uint, Float32: vk.FormatR32Sfloat, Float32Vec2: vk.FormatR32g32Sfloat, Float32Vec3: vk.FormatR32g32b32Sfloat, Float32Vec4: vk.FormatR32g32b32a32Sfloat, Float64: vk.FormatR64Sfloat, Float64Vec2: vk.FormatR64g64Sfloat, Float64Vec3: vk.FormatR64g64b64Sfloat, Float64Vec4: vk.FormatR64g64b64a64Sfloat, ImageRGBA32: vk.FormatR8g8b8a8Srgb, Depth32: vk.FormatD32Sfloat, Depth24Sten8: vk.FormatD24UnormS8Uint, }
VulkanTypes maps vgpu.Types to vulkan types
Functions ¶
func AllocBuffMem ¶
func AllocBuffMem(gp *GPU, dev vk.Device, buffer vk.Buffer, props vk.MemoryPropertyFlagBits) vk.DeviceMemory
AllocBuffMem allocates memory for given buffer, with given properties
func CheckExisting ¶
func CmdBeginOneTime ¶
func CmdBeginOneTime(cmd vk.CommandBuffer)
CmdBeginOneTime does BeginCommandBuffer with OneTimeSubmit set on buffer
func CmdReset ¶
func CmdReset(cmd vk.CommandBuffer)
CmdReset resets the command buffer so it is ready for recording new commands.
func CmdResetBegin ¶
func CmdResetBegin(cmd vk.CommandBuffer)
CmdResetBegin resets the command buffer so it is ready for recording new commands. and then calls CmdBegin to begin recording
func CmdSubmit ¶
func CmdSubmit(cmd vk.CommandBuffer, dev *Device)
CmdSubmit submits commands in buffer to given device queue, without any semaphore logic -- suitable for a WaitIdle logic.
func CmdSubmitWait ¶
func CmdSubmitWait(cmd vk.CommandBuffer, dev *Device)
CmdSubmitWait does Submit, WaitIdle on command Buffer
func DestroyBuffer ¶
DestroyBuffer destroys given buffer and nils the pointer
func DeviceExts ¶
func DeviceExts(gpu vk.PhysicalDevice) (names []string, err error)
DeviceExts gets a list of instance extensions available on the provided physical device.
func FindRequiredMemoryType ¶
func FindRequiredMemoryType(props vk.PhysicalDeviceMemoryProperties, deviceRequirements, hostRequirements vk.MemoryPropertyFlagBits) (uint32, bool)
func FindRequiredMemoryTypeFallback ¶
func FindRequiredMemoryTypeFallback(props vk.PhysicalDeviceMemoryProperties, deviceRequirements, hostRequirements vk.MemoryPropertyFlagBits) (uint32, bool)
func FindString ¶
FindString returns index of string if in list, else -1
func FreeBuffMem ¶
func FreeBuffMem(dev vk.Device, memory *vk.DeviceMemory)
FreeBuffMem frees given device memory to nil
func ImageToRGBA ¶ added in v1.0.3
ImageToRGBA returns image.RGBA version of given image either because it already is one, or by converting it.
func Init ¶ added in v1.0.6
func Init() error
Init initializes vulkan system for Display-enabled use, using glfw. Must call before doing any vgpu stuff. Calls glfw.Init and sets the Vulkan instance proc addr and calls Init. IMPORTANT: must be called on the main initial thread!
func InitNoDisplay ¶ added in v1.0.9
func InitNoDisplay() error
InitNoDisplay initializes vulkan system for a purely compute-based or headless operation, without any display (i.e., without using glfw). Call before doing any vgpu stuff. Loads the vulkan library and sets the Vulkan instance proc addr and calls Init. IMPORTANT: must be called on the main initial thread!
func InstanceExts ¶
InstanceExts gets a list of instance extensions available on the platform.
func MapMemoryAll ¶
MapMemoryAll maps the WholeSize of buffer memory, returning a pointer into start of buffer memory
func MemSizeAlign ¶
MemSizeAlign returns the size aligned according to align byte increments e.g., if align = 16 and size = 12, it returns 16
func NDescForTextures ¶
NDescForTextures returns number of descriptors (NDesc) required for given number of texture values.
func PlatformDefaults ¶ added in v1.0.0
func PlatformDefaults(gp *GPU)
func SafeString ¶
func SafeStrings ¶
func SaveImage ¶
SaveImage saves image to file, with format inferred from filename -- JPEG and PNG supported by default.
func SliceUint32 ¶
func Terminate ¶ added in v1.0.6
func Terminate()
Terminate shuts down the vulkan system -- call as last thing before quitting. IMPORTANT: must be called on the main initial thread!
func ValidationLayers ¶
ValidationLayers gets a list of validation layers available on the platform.
Types ¶
type BorderColors ¶
type BorderColors int32
Texture image sampler modes
const ( // Repeat the texture when going beyond the image dimensions. BorderTrans BorderColors = iota BorderBlack BorderWhite BorderColorsN )
func (*BorderColors) FromString ¶
func (i *BorderColors) FromString(s string) error
func (BorderColors) String ¶
func (i BorderColors) String() string
func (BorderColors) VkColor ¶
func (bc BorderColors) VkColor() vk.BorderColor
type BuffTypes ¶
type BuffTypes int32
BuffTypes are memory buffer types managed by the Memory object
const ( // VtxIdxBuff is a buffer holding Vertex and Index values VtxIdxBuff BuffTypes = iota // UniformBuff holds Uniform and UniformTexel objects: read-only, small footprint UniformBuff // StorageBuff holds Storage and StorageTexel: read-write, larger // mostly for compute shaders StorageBuff // TextureBuff holds Images / Textures -- hardware optimizes allocation // on device side, and staging-side is general TextureBuff BuffTypesN )
func (BuffTypes) AlignBytes ¶
AlignBytes returns alignment bytes for offsets into given buffer
func (*BuffTypes) FromString ¶
func (BuffTypes) IsReadOnly ¶
IsReadOnly returns true if buffer is read-only (most), else read-write (Storage)
type CmdPool ¶
type CmdPool struct { Pool vk.CommandPool Buff vk.CommandBuffer }
CmdPool is a command pool and buffer
func (*CmdPool) BeginCmd ¶
func (cp *CmdPool) BeginCmd() vk.CommandBuffer
BeginCmd does BeginCommandBuffer on buffer
func (*CmdPool) BeginCmdOneTime ¶
func (cp *CmdPool) BeginCmdOneTime() vk.CommandBuffer
BeginCmdOneTime does BeginCommandBuffer with OneTimeSubmit set on buffer
func (*CmdPool) ConfigResettable ¶
ConfigResettable configures the pool for persistent, resettable command buffers, used for rendering commands.
func (*CmdPool) ConfigTransient ¶
ConfigTransient configures the pool for transient command buffers, which are best used for random functions, such as memory copying. Use SubmitWaitFree logic.
func (*CmdPool) FreeBuffer ¶
FreeBuffer frees the current Buff buffer
func (*CmdPool) NewBuffer ¶
func (cp *CmdPool) NewBuffer(dv *Device) vk.CommandBuffer
NewBuffer makes a buffer in pool, setting Buff to point to it and also returning the buffer.
func (*CmdPool) Reset ¶
func (cp *CmdPool) Reset()
Reset resets the command buffer so it is ready for recording new commands.
func (*CmdPool) Submit ¶
Submit submits commands in buffer to given device queue, without any semaphore logic -- suitable for a WaitIdle logic.
func (*CmdPool) SubmitWait ¶
SubmitWait does End, Submit, WaitIdle on Buffer
func (*CmdPool) SubmitWaitFree ¶
SubmitWaitFree does End, Submit, WaitIdle, Free on Buffer
type Device ¶
type Device struct { Device vk.Device `desc:"logical device"` QueueIndex uint32 `desc:"queue index for device"` Queue vk.Queue `desc:"queue for device"` }
Device holds Device and associated Queue info
func (*Device) DeviceWaitIdle ¶ added in v1.0.4
func (dv *Device) DeviceWaitIdle()
DeviceWaitIdle waits until the device is idle and ready for commands -- maybe useful to call if getting not ready errors in particular situations
func (*Device) FindQueue ¶
func (dv *Device) FindQueue(gp *GPU, flags vk.QueueFlagBits) error
FindQueue finds queue for given flag bits, sets in QueueIndex returns error if not found.
func (*Device) Init ¶
func (dv *Device) Init(gp *GPU, flags vk.QueueFlagBits) error
Init initializes a device based on QueueFlagBits
func (*Device) MakeDevice ¶
MakeDevice and Queue based on QueueIndex
type Framebuffer ¶
type Framebuffer struct { Format ImageFormat `desc:"target framebuffer format -- if multisampling is active then Image has samples = 1, Render.Multi has full samples"` Image Image `desc:"the image behind the framebuffer, includes the format -- this "` Render *Render `desc:"pointer to the associated renderpass and depth buffer"` Framebuffer vk.Framebuffer `desc:"vulkan framebuffer"` HasCleared bool `desc:"has this framebuffer been cleared yet? if not, must be prior to use as a non-clearing Load case"` }
Framebuffer combines an Image and Render info (which has a depth buffer)
func (*Framebuffer) Config ¶
func (fb *Framebuffer) Config()
Config configures a new vulkan framebuffer object with current settings, destroying any existing
func (*Framebuffer) ConfigRender ¶
func (fb *Framebuffer) ConfigRender(rp *Render)
ConfigRender configures for Render, assuming image is already set and Configs the Framebuffer based on that.
func (*Framebuffer) ConfigRenderImage ¶
func (fb *Framebuffer) ConfigRenderImage(gp *GPU, dev vk.Device, fmt ImageFormat)
ConfigRenderImage configures a new image for a standalone framebuffer not associated with an existing surface, for RenderFrame target. In general it is recommended to use vk.SampleCount4Bit to avoid aliasing. Does not yet make the Framebuffer because it still needs the Render (see ConfigRender)
func (*Framebuffer) ConfigSurfaceImage ¶
func (fb *Framebuffer) ConfigSurfaceImage(gp *GPU, dev vk.Device, fmt ImageFormat, img vk.Image)
ConfigSurfaceImage configures settings for given existing surface image and format. Does not yet make the Framebuffer because it still needs the Render (see ConfigAll for all)
func (*Framebuffer) CopyToImage ¶
func (fb *Framebuffer) CopyToImage(toImg *Image, dev vk.Device, cmd vk.CommandBuffer)
CopyToImage copies the current framebuffer image to given image dest using given command buffer which must have the cmdBegin called already.
func (*Framebuffer) DestroyFrame ¶
func (fb *Framebuffer) DestroyFrame()
DestroyFrame destroys the framebuffer if non-nil
func (*Framebuffer) GrabImage ¶
func (fb *Framebuffer) GrabImage(dev vk.Device, cmd vk.CommandBuffer)
GrabImage grabs the current framebuffer image, using given command buffer which must have the cmdBegin called already.
type GPU ¶
type GPU struct { Instance vk.Instance `desc:"handle for the vulkan driver instance"` GPU vk.PhysicalDevice `desc:"handle for the vulkan physical GPU hardware"` AppName string `desc:"name of application -- set during Config and used in init of GPU"` APIVersion vk.Version `desc:"version of vulkan API to target"` AppVersion vk.Version `desc:"version of application -- optional"` InstanceExts []string `desc:"use Add method to add required instance extentions prior to calling Config"` DeviceExts []string `desc:"use Add method to add required device extentions prior to calling Config"` ValidationLayers []string `desc:"set Add method to add required validation layers prior to calling Config"` Compute bool `desc:"this is used for computing, not graphics"` DebugCallback vk.DebugReportCallback `desc:"our custom debug callback"` GPUProps vk.PhysicalDeviceProperties `desc:"properties of physical hardware -- populated after Config"` MemoryProps vk.PhysicalDeviceMemoryProperties `desc:"properties of device memory -- populated after Config"` }
GPU represents the GPU hardware
func NewComputeGPU ¶
func NewComputeGPU() *GPU
NewComputeGPU returns a new GPU struct with Compute Defaults set configure any additional defaults before calling Config. Use NewGPU for a graphics enabled GPU.
func NewGPU ¶
func NewGPU() *GPU
NewGPU returns a new GPU struct with Graphics Defaults set configure any additional defaults before calling Config. Use NewComputeGPU for a compute-only GPU that doesn't load graphics extensions.
func (*GPU) AddDeviceExt ¶
AddDeviceExt adds given extension(s), only if not already set returns true if added.
func (*GPU) AddInstanceExt ¶
AddInstanceExt adds given extension(s), only if not already set returns true if added.
func (*GPU) AddValidationLayer ¶
AddValidationLayer adds given validation layer, only if not already set returns true if added.
func (*GPU) Defaults ¶
Defaults sets up default parameters, with the graphics flag determining whether graphics-relevant items are added.
func (*GPU) Destroy ¶
func (gp *GPU) Destroy()
Destroy destroys GPU resources -- call after everything else has been destroyed
func (*GPU) NewComputeSystem ¶
NewComputeSystem returns a new system initialized for this GPU, for Compute, not graphics functionality.
func (*GPU) NewGraphicsSystem ¶
NewGraphicsSystem returns a new system initialized for this GPU, for graphics functionality, using Device from the Surface or RenderFrame depending on the target of rendering.
func (*GPU) PropsString ¶
PropsString returns a human-readable summary of the GPU properties.
type HostImage ¶
type HostImage struct { Size int `desc:"size in bytes allocated for host representation of image"` Buff vk.Buffer `view:"-" desc:"buffer for host CPU-visible memory, for staging -- can be owned by us or managed by Memory (for Val)"` Offset int `desc:"offset into host buffer, when Buff is Memory managed"` Mem vk.DeviceMemory `view:"-" desc:"host CPU-visible memory, for staging, when we manage our own memory"` Ptr unsafe.Pointer `view:"-" desc:"memory mapped pointer into host memory -- remains mapped"` }
HostImage is the host representation of an Image
type Image ¶
type Image struct { Name string `` /* 153-byte string literal not displayed */ Flags int32 `desc:"bit flags for image state, for indicating nature of ownership and state"` Format ImageFormat `desc:"format & size of image"` Image vk.Image `view:"-" desc:"vulkan image handle, in device memory"` View vk.ImageView `view:"-" desc:"vulkan image view"` Mem vk.DeviceMemory `view:"-" desc:"memory for image when we allocate it"` Dev vk.Device `view:"-" desc:"keep track of device for destroying view"` Host HostImage `desc:"host memory buffer representation of the image"` GPU *GPU `desc:"pointer to our GPU"` }
Image represents a vulkan image with an associated ImageView. The vulkan Image is in device memory, in an optimized format. There can also be an optional host-visible, plain pixel buffer which can be a pointer into a larger buffer or owned by the Image.
func (*Image) AllocHost ¶
func (im *Image) AllocHost()
AllocHost allocates a staging buffer on the host for the image on the device (must set first), based on the current Format info, and other flags. If the existing host buffer is sufficient to hold the image, then nothing happens.
func (*Image) AllocImage ¶
func (im *Image) AllocImage()
AllocImage allocates the VkImage on the device (must set first), based on the current Format info, and other flags.
func (*Image) ConfigDepth ¶
ConfigDepth configures this image as a depth image using given depth image format, and other on format information from the render image format.
func (*Image) ConfigDepthView ¶
func (im *Image) ConfigDepthView()
ConfigDepthView configures a depth view image
func (*Image) ConfigFramebuffer ¶
func (im *Image) ConfigFramebuffer(gp *GPU, dev vk.Device, imgFmt *ImageFormat)
ConfigFramebuffer configures this image as a framebuffer image using format. Sets multisampling to 1, layers to 1. Only makes a device image -- no host rep.
func (*Image) ConfigGoImage ¶
ConfigGoImage configures the image for storing an image of the given size, for images allocated in a shared host buffer. (i.e., not Var.TextureOwns). Image format will be set to default unless format is already set. Layers is number of separate images of given size allocated in a texture array. Once memory is allocated then SetGoImage can be called in a second pass.
func (*Image) ConfigMulti ¶
func (im *Image) ConfigMulti(gp *GPU, dev vk.Device, imgFmt *ImageFormat)
ConfigMulti configures this image as a mutisampling image using format. Only makes a device image -- no host rep.
func (*Image) ConfigStdView ¶
func (im *Image) ConfigStdView()
ConfigStdView configures a standard 2D image view, for current image, format, and device.
func (*Image) ConfigValHost ¶
ConfigValHost configures host staging buffer from memory buffer for val-owned image
func (*Image) CopyImageRec ¶
CopyImageRec returns info for this Image for the ImageCopy operations
func (*Image) CopyRec ¶
func (im *Image) CopyRec() vk.BufferImageCopy
CopyRec returns info for this Image for the BufferImageCopy operations
func (*Image) DevGoImage ¶
DevGoImage returns an *image.RGBA standard Go image, of the Device memory representation. Only works if ImageOnHostOnly and Format is default vk.FormatR8g8b8a8Srgb (strongly recommended in any case)
func (*Image) FreeHost ¶
func (im *Image) FreeHost()
FreeHost frees memory in host buffer representation of image Only if we own the host buffer.
func (*Image) FreeImage ¶
func (im *Image) FreeImage()
FreeImage frees device memory version of image that we own
func (*Image) GoImage ¶
GoImage returns an *image.RGBA standard Go image, of the Host memory representation at given layer. Only works if IsHostActive and Format is default vk.FormatR8g8b8a8Srgb (strongly recommended in any case)
func (*Image) HasFlag ¶
func (im *Image) HasFlag(flag ImageFlags) bool
HasFlag checks if flag is set using atomic, safe for concurrent access
func (*Image) HostPixels ¶
HostPixels returns host staging pixels at given layer
func (*Image) IsHostActive ¶
IsHostActive returns true if the Host accessible version of image is active and ready to use
func (*Image) IsHostOwner ¶
IsHostOwner returns true if the host buffer is owned by us
func (*Image) IsImageOwner ¶
IsImageOwner returns true if the vk.Image is owned by us
func (*Image) SetGoImage ¶
SetGoImage sets staging image data from a standard Go image at given layer. This is most efficiently done using an image.RGBA, but other formats will be converted as necessary. If flipY is true then the Image Y axis is flipped when copying into the image data, so that images will appear upright in the standard OpenGL Y-is-up coordinate system. If using the Y-is-down Vulkan coordinate system, don't flip. Only works if IsHostActive and Image Format is default vk.FormatR8g8b8a8Srgb, Must still call AllocImage to have image allocated on the device, and copy from this host staging data to the device.
func (*Image) SetSize ¶
SetSize sets the size. If the size is not the same as current, and Image owns the Host and / or Image, then those are resized. returns true if resized.
func (*Image) SetVkImage ¶
SetVkImage sets a Vk Image and configures a default 2D view based on existing format information (which must be set properly). Any exiting view is destroyed first. Must pass the relevant device.
func (*Image) Transition ¶
func (im *Image) Transition(cmd vk.CommandBuffer, format vk.Format, oldLayout, newLayout vk.ImageLayout, srcStage, dstStage vk.PipelineStageFlagBits)
Transition transitions image to new layout
func (*Image) TransitionDstToGeneral ¶
func (im *Image) TransitionDstToGeneral(cmd vk.CommandBuffer)
TransitionDstToGeneral transitions from Dst to General, in prep for copy from dev to host
func (*Image) TransitionDstToShader ¶
func (im *Image) TransitionDstToShader(cmd vk.CommandBuffer)
TransitionDstToShader transitions from TransferDstOptimal to TransferShaderReadOnly
func (*Image) TransitionForDst ¶
func (im *Image) TransitionForDst(cmd vk.CommandBuffer, srcStage vk.PipelineStageFlagBits)
TransitionForDst transitions to TransferDstOptimal to prepare device image to be copied to. source stage is as specified.
type ImageFlags ¶
type ImageFlags int32
ImageFlags are bitflags for Image state
const ( // ImageActive: the Image and ImageView are configured and ready to use ImageActive ImageFlags = iota // ImageHostActive: the Host representation of the image is present and // ready to be accessed ImageHostActive // ImageOwnsImage: we own the Vk.Image ImageOwnsImage // ImageOwnsHost: we own the Host buffer (and it is initialized) ImageOwnsHost // ImageIsVal: we are a Val image and our Host buffer is shared, with offset. // this is incompatible with ImageOwnsHost ImageIsVal // DepthImage indicates that this is a Depth buffer image DepthImage // FramebufferImage indicates that this is a Framebuffer image FramebufferImage // ImageOnHostOnly causes the image to be created only on host visible // memory, not on device memory -- no additional host buffer should be created. // this is for an ImageGrab image. layout is LINEAR ImageOnHostOnly ImageFlagsN )
func (*ImageFlags) FromString ¶
func (i *ImageFlags) FromString(s string) error
func (ImageFlags) String ¶
func (i ImageFlags) String() string
type ImageFormat ¶
type ImageFormat struct { Size image.Point `desc:"Size of image"` Format vk.Format `desc:"Image format -- FormatR8g8b8a8Srgb is a standard default"` Samples vk.SampleCountFlagBits `desc:"number of samples -- set higher for Framebuffer rendering but otherwise default of SampleCount1Bit"` Layers int `desc:"number of layers for texture arrays"` }
ImageFormat describes the size and vulkan format of an Image If Layers > 1, all must be the same size.
func NewImageFormat ¶
func NewImageFormat(width, height, layers int) *ImageFormat
NewImageFormat returns a new ImageFormat with default format and given size and number of layers
func (*ImageFormat) Aspect ¶
func (im *ImageFormat) Aspect() float32
Aspect returns the aspect ratio X / Y
func (*ImageFormat) Bounds ¶
func (im *ImageFormat) Bounds() image.Rectangle
Bounds returns the rectangle defining this image: 0,0,w,h
func (*ImageFormat) BytesPerPixel ¶
func (im *ImageFormat) BytesPerPixel() int
BytesPerPixel returns number of bytes required to represent one Pixel (in Host memory at least). TODO only works for known formats -- need to add more as needed.
func (*ImageFormat) Defaults ¶
func (im *ImageFormat) Defaults()
func (*ImageFormat) IsStdRGBA ¶
func (im *ImageFormat) IsStdRGBA() bool
IsStdRGBA returns true if image format is the standard vk.FormatR8g8b8a8Srgb format which is compatible with go image.RGBA format.
func (*ImageFormat) LayerByteSize ¶
func (im *ImageFormat) LayerByteSize() int
LayerByteSize returns number of bytes required to represent one layer of image in Host memory. TODO only works for known formats -- need to add more as needed.
func (*ImageFormat) Set ¶
func (im *ImageFormat) Set(w, h int, ft vk.Format)
Set sets width, height and format
func (*ImageFormat) SetFormat ¶
func (im *ImageFormat) SetFormat(ft Types)
SetFormat sets the format using vgpu standard Types
func (*ImageFormat) SetMultisample ¶
func (im *ImageFormat) SetMultisample(nsamp int)
SetMultisample sets the number of multisampling to decrease aliasing 4 is typically sufficient. Values must be power of 2.
func (*ImageFormat) SetSize ¶
func (im *ImageFormat) SetSize(w, h int)
SetSize sets the width, height
func (*ImageFormat) Size32 ¶
func (im *ImageFormat) Size32() (width, height uint32)
Size32 returns size as uint32 values
func (*ImageFormat) Stride ¶
func (im *ImageFormat) Stride() int
Stride returns number of bytes per image row. TODO only works for known formats -- need to add more as needed.
func (*ImageFormat) String ¶
func (im *ImageFormat) String() string
String returns human-readable version of format
func (*ImageFormat) TotalByteSize ¶
func (im *ImageFormat) TotalByteSize() int
TotalByteSize returns total number of bytes required to represent all layers of images in Host memory. TODO only works for known formats -- need to add more as needed.
type MemBuff ¶
type MemBuff struct { GPU *GPU Type BuffTypes `desc:"type of memory in this buffer"` Size int `desc:"allocated buffer size"` Host vk.Buffer `view:"-" desc:"logical descriptor for host CPU-visible memory, for staging"` HostMem vk.DeviceMemory `view:"-" desc:"host CPU-visible memory, for staging"` Dev vk.Buffer `view:"-" desc:"logical descriptor for device GPU-local memory, for computation"` DevMem vk.DeviceMemory `view:"-" desc:"device GPU-local memory, for computation"` HostPtr unsafe.Pointer `view:"-" desc:"memory mapped pointer into host memory -- remains mapped"` AlignBytes int `desc:"alignment of offsets into this buffer"` Active bool `inactive:"+" desc:"true if memory has been allocated, copied, transfered"` }
MemBuff is a memory buffer holding a particular type of memory with staging Host-based memory and Device memory
func (*MemBuff) AllocHost ¶
AllocHost allocates memory for this buffer of given size in bytes, freeing any existing memory allocated first. Host and Dev buffers are made, and host memory is allocated and mapped for staging purposes. Call AllocDev to allocate device memory. Returns true if new memory was allocated.
type Memory ¶
type Memory struct { GPU *GPU Device Device `desc:"logical device that this memory is managed for -- set from System"` CmdPool CmdPool `desc:"command pool for memory transfers"` Vars Vars `desc:"Vars variables used in shaders, which manage associated Vals containing specific value instances of each var"` Buffs [BuffTypesN]*MemBuff `desc:"memory buffers, organized by different Roles of vars"` }
Memory manages memory for the GPU, using separate buffers for different roles, defined in the BuffTypes and managed by a MemBuff. Memory is organized by Vars with associated Vals.
func (*Memory) AllocBuffMem ¶
func (mm *Memory) AllocBuffMem(buffer vk.Buffer, props vk.MemoryPropertyFlagBits) vk.DeviceMemory
AllocBuffMem allocates memory for given buffer, with given properties
func (*Memory) AllocDev ¶
func (mm *Memory) AllocDev()
AllocDev allocates device memory for all bufers
func (*Memory) AllocDevBuff ¶
AllocDevBuff allocates memory on the device for given buffer
func (*Memory) AllocHostBuff ¶
AllocHostBuff allocates host memory for given buffer
func (*Memory) Config ¶
Config should be called after all Vals have been configured and are ready to go with their initial data. Does: AllocHost(), AllocDev()
func (*Memory) Deactivate ¶
func (mm *Memory) Deactivate()
Deactivate deactivates device memory for all buffs
func (*Memory) DeactivateBuff ¶
DeactivateBuff deactivates device memory in given buffer
func (*Memory) FreeBuffMem ¶
func (mm *Memory) FreeBuffMem(memory *vk.DeviceMemory)
FreeBuffMem frees given device memory to nil
func (*Memory) Init ¶
Init configures the Memory for use with given gpu, device, and associated queueindex
func (*Memory) SyncToGPU ¶
func (mm *Memory) SyncToGPU()
SyncToGPU syncs all modified Val regions from CPU to GPU device memory, for all buffs
func (*Memory) SyncToGPUBuff ¶
SyncToGPUBuff syncs all modified Val regions from CPU to GPU device memory, for given buff
func (*Memory) SyncValFmGPU ¶
SyncValFmGPU syncs given value from GPU device memory to CPU host memory. Must be in Storage memory -- otherwise an error will be printed and returned.
func (*Memory) SyncValIdxFmGPU ¶
SyncValIdxFmGPU syncs given value from GPU device memory to CPU host memory, specifying value by index for given named variable, in given set. Variable can only only be Storage memory -- otherwise an error is returned.
func (*Memory) SyncValNameFmGPU ¶
SyncValNameFmGPU syncs given value from GPU device memory to CPU host memory, specifying value by name for given named variable in given set. Variable can only only be Storage memory -- otherwise an error is returned.
func (*Memory) SyncValsTextures ¶
SyncValsTextures syncs all changed vals images from host buffer to device memory
func (*Memory) TransferAllValsTextures ¶
TransferAllValsTextures copies all vals images from host buffer to device memory
func (*Memory) TransferImagesFmGPU ¶
TransferImagesFmGPU transfers image memory from GPU to CPU for given images. the image Host.Offset *must* be accurate for the given buffer, whether its own individual buffer or the shared memory-managed buffer.
func (*Memory) TransferRegsFmGPU ¶
TransferRegsFmGPU transfers memory from GPU to CPU for given regions
func (*Memory) TransferRegsToGPU ¶
TransferRegsToGPU transfers memory from CPU to GPU for given regions
func (*Memory) TransferTexturesToGPU ¶
TransferTexturesToGPU transfers texture image memory from CPU to GPU for given images. Transitions device image as destination, then to Shader read only source, for use in fragment shader texture sampling. The image Host.Offset *must* be accurate for the given buffer, whether its own individual buffer or the shared memory-managed buffer.
func (*Memory) TransferToGPU ¶
func (mm *Memory) TransferToGPU()
TransferToGPU transfers entire staging to GPU for all buffs
func (*Memory) TransferToGPUBuff ¶
TransferToGPUBuff transfers entire staging to GPU for given buffer
type Pipeline ¶
type Pipeline struct { Name string `desc:"unique name of this pipeline"` Sys *System `desc:"system that we belong to and manages all shared resources (Memory, Vars, Vals, etc), etc"` Shaders []*Shader `desc:"shaders in order added -- should be execution order"` ShaderMap map[string]*Shader `desc:"shaders loaded for this pipeline"` VkConfig vk.GraphicsPipelineCreateInfo `desc:"vulkan pipeline configuration options"` VkPipeline vk.Pipeline `desc:"the created vulkan pipeline"` VkCache vk.PipelineCache `desc:"cache"` }
Pipeline manages Shader program(s) that accomplish a specific type of rendering or compute function, using Vars / Vals defined by the overall System. In the graphics context, each pipeline could handle a different class of materials (textures, Phong lighting, etc).
func (*Pipeline) AddShader ¶
func (pl *Pipeline) AddShader(name string, typ ShaderTypes) *Shader
AddShader adds Shader with given name and type to the pipeline
func (*Pipeline) AddShaderCode ¶
func (pl *Pipeline) AddShaderCode(name string, typ ShaderTypes, code []byte) *Shader
AddShaderCode adds Shader with given name and type to the pipeline, Loading SPV code from given bytes
func (*Pipeline) AddShaderFile ¶
func (pl *Pipeline) AddShaderFile(name string, typ ShaderTypes, fname string) *Shader
AddShaderFile adds Shader with given name and type to the pipeline, Opening SPV code from given filename
func (*Pipeline) BindDrawVertex ¶
func (pl *Pipeline) BindDrawVertex(cmd vk.CommandBuffer, descIdx int)
BindDrawVertex adds commands to the given command buffer to bind this pipeline, and then bind vertex / index values and Draw based on current vals for any Vertex (and associated Index) Vars. for given descIdx set of descriptors (see Vars NDescs for info). This is the standard unit of drawing between Begin and End.
func (*Pipeline) BindPipeline ¶
func (pl *Pipeline) BindPipeline(cmd vk.CommandBuffer)
BindPipeline adds commands to the given command buffer to bind this pipeline to command buffer. System BeginRenderPass must have been called at some point before this.
func (*Pipeline) ComputeCommand ¶
ComputeCommand adds commands to run the compute shader for given number of computational elements along 3 dimensions, which are passed as indexes into the shader. Can use subsets of dimensions by using 1 for the other dimensions. Uses the system CmdPool -- must have a CmdBegin already executed, either via ComputeBindVars or ComputeResetBegin call. Must call CommandSubmit[Wait] to execute the command.
func (*Pipeline) Config ¶
func (pl *Pipeline) Config()
Config is called once all the VkConfig options have been set using Set* methods, and the shaders have been loaded. The parent System has already done what it can for its config
func (*Pipeline) ConfigCompute ¶
func (pl *Pipeline) ConfigCompute()
ConfigCompute does the configuration for a Compute pipeline
func (*Pipeline) ConfigStages ¶
func (pl *Pipeline) ConfigStages()
ConfigStages configures the shader stages
func (*Pipeline) DestroyPipeline ¶ added in v1.0.0
func (pl *Pipeline) DestroyPipeline()
func (*Pipeline) Draw ¶
func (pl *Pipeline) Draw(cmd vk.CommandBuffer, vtxCount, instanceCount, firstVtx, firstInstance int)
Draw adds CmdDraw command to the given command buffer BindPipeline must have been called before this. SeeDrawVertex for more typical case using Vertex (and Index) variables.
func (*Pipeline) DrawVertex ¶
func (pl *Pipeline) DrawVertex(cmd vk.CommandBuffer, descIdx int)
DrawVertex adds commands to the given command buffer to bind vertex / index values and Draw based on current BindVertexVal setting for any Vertex (and associated Index) Vars, for given descIdx set of descriptors (see Vars NDescs for info).
func (*Pipeline) FreeShaders ¶
func (pl *Pipeline) FreeShaders()
FreeShaders is called after successful pipeline creation, to unload shader modules as they are no longer needed
func (*Pipeline) InitPipeline ¶
func (pl *Pipeline) InitPipeline()
func (*Pipeline) Push ¶
Push pushes given value as a push constant for given registered push constant variable. Note: it is *essential* to use a local, stack variable for the push value as cgo will likely complain if it is inside some other structure. BindPipeline must have been called before this.
func (*Pipeline) SetColorBlend ¶
SetColorBlend determines the color blending function: either 1-source alpha (alphaBlend) or no blending: new color overwrites old. Default is alphaBlend = true
func (*Pipeline) SetCullFace ¶
SetCullFace sets the face culling mode: true = back, false = front use CullBack, CullFront constants
func (*Pipeline) SetDynamicState ¶
func (pl *Pipeline) SetDynamicState()
SetDynamicState sets dynamic state (Scissor, Viewport, what else?)
func (*Pipeline) SetFrontFace ¶
SetFrontFace sets the winding order for what counts as a front face true = CCW, false = CW
func (*Pipeline) SetGraphicsDefaults ¶
func (pl *Pipeline) SetGraphicsDefaults()
SetGraphicsDefaults configures all the default settings for a graphics rendering pipeline (not for a compute pipeline)
func (*Pipeline) SetLineWidth ¶
SetLineWidth sets the rendering line width -- 1 is default.
func (*Pipeline) SetRasterization ¶
func (pl *Pipeline) SetRasterization(polygonMode vk.PolygonMode, cullMode vk.CullModeFlagBits, frontFace vk.FrontFace, lineWidth float32)
SetRasterization sets various options for how to rasterize shapes: Defaults are: vk.PolygonModeFill, vk.CullModeBackBit, vk.FrontFaceCounterClockwise, 1.0 There are also separate methods for CullFace, FrontFace, and LineWidth
func (*Pipeline) SetTopology ¶
func (pl *Pipeline) SetTopology(topo Topologies, restartEnable bool)
SetTopology sets the topology of vertex position data. TriangleList is the default. Also for Strip modes, restartEnable allows restarting a new strip by inserting a ??
func (*Pipeline) ShaderByName ¶
ShaderByName returns Shader by name. Returns nil if not found (error auto logged).
type Render ¶
type Render struct { Sys *System `desc:"system that we belong to and manages all shared resources (Memory, Vars, Vals, etc), etc"` Dev vk.Device `desc:"the device we're associated with -- this must be the same device that owns the Framebuffer -- e.g., the Surface"` Format ImageFormat `desc:"image format information for the framebuffer we render to"` Depth Image `desc:"the associated depth buffer, if set"` HasDepth bool `desc:"is true if configured with depth buffer"` Multi Image `desc:"for multisampling, this is the multisampled image that is the actual render target"` HasMulti bool `desc:"is true if multsampled image configured"` Grab Image `` /* 202-byte string literal not displayed */ NotSurface bool `desc:"set this to true if it is not using a Surface render target (i.e., it is a RenderFrame)"` ClearVals []vk.ClearValue `desc:"values for clearing image when starting render pass"` VkClearPass vk.RenderPass `desc:"the vulkan renderpass config that clears target first"` VkLoadPass vk.RenderPass `desc:"the vulkan renderpass config that does not clear target first (loads previous)"` }
Render manages various elements needed for rendering, including a vulkan RenderPass object, which specifies parameters for rendering to a Framebuffer. It holds the Depth buffer if one is used, and a multisampling image too. The Render object lives on the System, and any associated Surface, RenderFrame, and Framebuffers point to it.
func (*Render) BeginRenderPass ¶
func (rp *Render) BeginRenderPass(cmd vk.CommandBuffer, fr *Framebuffer)
BeginRenderPass adds commands to the given command buffer to start the render pass on given framebuffer. Clears the frame first, according to the ClearVals See BeginRenderPassNoClear for non-clearing version.
func (*Render) BeginRenderPassImpl ¶
func (rp *Render) BeginRenderPassImpl(cmd vk.CommandBuffer, fr *Framebuffer, clear bool)
BeginRenderPassImpl adds commands to the given command buffer to start the render pass on given framebuffer. If clear = true, clears the frame according to the ClearVals.
func (*Render) BeginRenderPassNoClear ¶
func (rp *Render) BeginRenderPassNoClear(cmd vk.CommandBuffer, fr *Framebuffer)
BeginRenderPassNoClear adds commands to the given command buffer to start the render pass on given framebuffer. does NOT clear the frame first -- loads prior state.
func (*Render) Config ¶
Config configures the render pass for given device, Using standard parameters for graphics rendering, based on the given image format and depth image format (pass UndefType for no depth buffer).
func (*Render) ConfigGrab ¶
ConfigGrab configures the Grab for copying rendered image back to host memory. Uses format of current Image.
func (*Render) ConfigImpl ¶
func (rp *Render) ConfigImpl(dev vk.Device, imgFmt *ImageFormat, depthFmt Types, clear bool) vk.RenderPass
func (*Render) SetClearColor ¶
SetClearColor sets the RGBA colors to set when starting new render
func (*Render) SetClearDepthStencil ¶
SetClearDepthStencil sets the depth and stencil values when starting new render
type RenderFrame ¶
type RenderFrame struct { GPU *GPU `desc:"pointer to gpu device, for convenience"` Device Device `desc:"device for this surface -- each window surface has its own device, configured for that surface"` Render *Render `desc:"the Render for this RenderFrame, typically from a System"` Format ImageFormat `desc:"has the current image format and dimensions"` NFrames int `` /* 182-byte string literal not displayed */ Frames []*Framebuffer `` /* 126-byte string literal not displayed */ ImageAcquired vk.Semaphore `view:"-" desc:"semaphore used internally for waiting on acquisition of next frame"` RenderDone vk.Semaphore `` /* 130-byte string literal not displayed */ RenderFence vk.Fence `view:"-" desc:"fence for rendering command running"` OwnDevice bool `desc:"do we own the device?"` }
RenderFrame is an offscreen, non-window-backed rendering target, functioning like a Surface
func NewRenderFrame ¶
func NewRenderFrame(gp *GPU, dev *Device, size image.Point) *RenderFrame
NewRenderFrame returns a new renderframe initialized for given GPU, of given size. using given device, e.g., from a Surface -- to transition images from renderframe to surface, they must use the same device. if device is nil, own device is created.
func NewRenderFrameOwnDevice ¶
func NewRenderFrameOwnDevice(gp *GPU, size image.Point) *RenderFrame
NewRenderFrameOwnDevice returns a new renderframe initialized for given GPU, of given size. This version creates a new Graphics device -- for purely offscreen usage.
func (*RenderFrame) Defaults ¶
func (rf *RenderFrame) Defaults()
func (*RenderFrame) Destroy ¶
func (rf *RenderFrame) Destroy()
func (*RenderFrame) Free ¶
func (rf *RenderFrame) Free()
Free frees any existing (for ReInit or Destroy)
func (*RenderFrame) GrabImage ¶
func (rf *RenderFrame) GrabImage(cmd vk.CommandBuffer, idx int)
GrabImage grabs rendered image of given index to Framebuffer.ImageGrab. must have waited for render already.
func (*RenderFrame) Init ¶
func (rf *RenderFrame) Init(gp *GPU, makeDevice bool) error
Init initializes the device and all other resources for the renderframe.
func (*RenderFrame) ReConfigFrames ¶
func (rf *RenderFrame) ReConfigFrames()
ReConfigFrames re-configures the Famebuffers using exiting settings. Assumes Config has been called.
func (*RenderFrame) SetRender ¶
func (rf *RenderFrame) SetRender(rp *Render)
SetRender sets the Render and updates frames accordingly
func (*RenderFrame) SetSize ¶
func (rf *RenderFrame) SetSize(size image.Point) bool
SetSize sets the size for the render frame, doesn't do anything if already that size (returns fale)
func (*RenderFrame) SubmitRender ¶
func (rf *RenderFrame) SubmitRender(cmd vk.CommandBuffer)
SubmitRender submits a rendering command that must have been added to the given command buffer, calling CmdEnd on the buffer first. This buffer triggers the associated Fence logic to control the sequencing of render commands over time. The ImageAcquired semaphore before the command is run.
func (*RenderFrame) WaitForRender ¶
func (rf *RenderFrame) WaitForRender()
WaitForRender waits until the last submitted render completes
type Sampler ¶
type Sampler struct { Name string UMode SamplerModes `desc:"for U (horizontal) axis -- what to do when going off the edge"` VMode SamplerModes `desc:"for V (vertical) axis -- what to do when going off the edge"` WMode SamplerModes `desc:"for W (horizontal) axis -- what to do when going off the edge"` Border BorderColors `desc:"border color for Clamp modes"` VkSampler vk.Sampler `desc:"the vulkan sampler"` }
Sampler represents a vulkan image sampler
type SamplerModes ¶
type SamplerModes int32
Texture image sampler modes
const ( // Repeat the texture when going beyond the image dimensions. Repeat SamplerModes = iota // Like repeat, but inverts the coordinates to mirror the image when going beyond the dimensions. MirroredRepeat // Take the color of the edge closest to the coordinate beyond the image dimensions. ClampToEdge // Return a solid color when sampling beyond the dimensions of the image. ClampToBorder // Like clamp to edge, but instead uses the edge opposite to the closest edge. MirrorClampToEdge SamplerModesN )
func (*SamplerModes) FromString ¶
func (i *SamplerModes) FromString(s string) error
func (SamplerModes) String ¶
func (i SamplerModes) String() string
func (SamplerModes) VkMode ¶
func (sm SamplerModes) VkMode() vk.SamplerAddressMode
type Shader ¶
type Shader struct { Name string Type ShaderTypes VkModule vk.ShaderModule }
Shader manages a single Shader program
func (*Shader) Free ¶
Free deletes the shader module, which can be done after the pipeline is created.
func (*Shader) Init ¶
func (sh *Shader) Init(name string, typ ShaderTypes)
Init initializes the shader
type ShaderTypes ¶
type ShaderTypes int32
ShaderTypes is a list of GPU shader types
const ( VertexShader ShaderTypes = iota TessCtrlShader TessEvalShader GeometryShader FragmentShader ComputeShader AllShaders )
type StackFrame ¶
type StackFrame struct { File string LineNumber int Name string Package string ProgramCounter uintptr }
A StackFrame contains all necessary information about to generate a line in a callstack.
func (*StackFrame) Func ¶
func (frame *StackFrame) Func() *runtime.Func
Func returns the function that this stackframe corresponds to
func (*StackFrame) SourceLine ¶
func (frame *StackFrame) SourceLine() (string, error)
SourceLine gets the line of code (from File and Line) of the original source if possible
func (*StackFrame) String ¶
func (frame *StackFrame) String() string
String returns the stackframe formatted in the same way as go does in runtime/debug.Stack()
type Surface ¶
type Surface struct { GPU *GPU `desc:"pointer to gpu device, for convenience"` Device Device `desc:"device for this surface -- each window surface has its own device, configured for that surface"` Render *Render `desc:"the Render for this Surface, typically from a System"` Format ImageFormat `desc:"has the current swapchain image format and dimensions"` DesiredFormats []vk.Format `desc:"ordered list of surface formats to select"` NFrames int `` /* 182-byte string literal not displayed */ Frames []*Framebuffer `` /* 130-byte string literal not displayed */ Surface vk.Surface `view:"-" desc:"vulkan handle for surface"` Swapchain vk.Swapchain `view:"-" desc:"vulkan handle for swapchain"` ImageAcquired vk.Semaphore `view:"-" desc:"semaphore used internally for waiting on acquisition of next frame"` RenderDone vk.Semaphore `` /* 130-byte string literal not displayed */ RenderFence vk.Fence `view:"-" desc:"fence for rendering command running"` }
Surface manages the physical device for the visible image of a window surface, and the swapchain for presenting images.
func NewSurface ¶
NewSurface returns a new surface initialized for given GPU and vulkan Surface handle, obtained from a valid window.
func (*Surface) AcquireNextImage ¶
AcquireNextImage gets the next frame index to render to. It automatically handles any issues with out-of-date swapchain. It triggers the ImageAcquired semaphore when image actually acquired. Must call SubmitRender with command to launch command contingent on that semaphore.
func (*Surface) ConfigSwapchain ¶
func (sf *Surface) ConfigSwapchain()
ConfigSwapchain configures the swapchain for surface. This assumes that all existing items have been destroyed.
func (*Surface) FreeSwapchain ¶
func (sf *Surface) FreeSwapchain()
FreeSwapchain frees any existing swawpchain (for ReInit or Destroy)
func (*Surface) Init ¶
Init initializes the device and all other resources for the surface based on the vulkan surface handle which must be obtained from the OS-specific window, created first (e.g., via glfw)
func (*Surface) PresentImage ¶
PresentImage waits on the RenderDone semaphore to present the rendered image to the surface, for the given frame index, as returned by AcquireNextImage.
func (*Surface) ReConfigFrames ¶
func (sf *Surface) ReConfigFrames()
ReConfigFrames re-configures the Famebuffers using exiting settings. Assumes ConfigSwapchain has been called.
func (*Surface) ReConfigSwapchain ¶
func (sf *Surface) ReConfigSwapchain()
ReConfigSwapchain does a re-initialize of swapchain, freeing existing. This must be called when the window is resized.
func (*Surface) SubmitRender ¶
func (sf *Surface) SubmitRender(cmd vk.CommandBuffer)
SubmitRender submits a rendering command that must have been added to the given command buffer, calling CmdEnd on the buffer first. This buffer triggers the associated Fence logic to control the sequencing of render commands over time. The ImageAcquired semaphore efore the command is run.
type System ¶
type System struct { Name string `desc:"optional name of this System"` GPU *GPU `desc:"gpu device"` Device Device `desc:"logical device for this System, which is a non-owned copy of either Surface or RenderFrame device"` CmdPool CmdPool `desc:"cmd pool specific to this system"` Compute bool `desc:"if true, this is a compute system -- otherwise is graphics"` Pipelines []*Pipeline `desc:"all pipelines"` PipelineMap map[string]*Pipeline `desc:"map of all pipelines -- names must be unique"` Mem Memory `desc:"manages all the memory for all the Vals"` Render Render `desc:"renderpass with depth buffer for this system"` }
System manages a system of Pipelines that all share a common collection of Vars, Vals, and a Memory manager. For example, this could be a collection of different pipelines for different material types, or different compute operations performed on a common set of data. It maintains its own logical device and associated queue.
func (*System) AddPipeline ¶
AddPipeline adds given pipeline
func (*System) BeginRenderPass ¶
func (sy *System) BeginRenderPass(cmd vk.CommandBuffer, fr *Framebuffer, descIdx int)
BeginRenderPass adds commands to the given command buffer to start the render pass on given framebuffer. Clears the frame first, according to the ClearVals. Also Binds descriptor sets to command buffer for given collection of descriptors descIdx (see Vars NDescs for info).
func (*System) BeginRenderPassNoClear ¶
func (sy *System) BeginRenderPassNoClear(cmd vk.CommandBuffer, fr *Framebuffer, descIdx int)
BeginRenderPassNoClear adds commands to the given command buffer to start the render pass on given framebuffer. does NOT clear the frame first -- loads prior state. Also Binds descriptor sets to command buffer for given collection of descriptors descIdx (see Vars NDescs for info).
func (*System) CmdBindTextureVarIdx ¶
func (sy *System) CmdBindTextureVarIdx(cmd vk.CommandBuffer, setIdx int, varNm string, valIdx int) (txIdx, descIdx int, switched bool, err error)
CmdBindTextureVarIdx returns the txIdx needed to select the given Texture value at valIdx in given variable in given set index, for use in a shader (i.e., pass txIdx as a push constant to the shader to select this texture). If there are more than MaxTexturesPerSet textures, then it may need to select a different descIdx where that val has been allocated -- the descIdx is returned, and switched is true if it had to issue a CmdBindVars to given command buffer to bind to that desc set, updating BindDescIdx. Typically other vars are bound to the same vals across sets, so this should not affect them, but that is not necessarily the case, so other steps might need to be taken. If the texture is not valid, a -1 is returned for txIdx, and an error is logged.
func (*System) CmdBindVars ¶
func (sy *System) CmdBindVars(cmd vk.CommandBuffer, descIdx int)
CmdBindVars adds command to the given command buffer to bind the Vars descriptors, for given collection of descriptors descIdx (see Vars NDescs for info).
func (*System) CmdResetBindVars ¶
func (sy *System) CmdResetBindVars(cmd vk.CommandBuffer, descIdx int)
CmdResetBindVars adds command to the given command buffer to bind the Vars descriptors, for given collection of descriptors descIdx (see Vars NDescs for info).
func (*System) CmdSubmitWait ¶ added in v1.0.8
func (sy *System) CmdSubmitWait()
CmdSubmitWait does SubmitWait on CmdPool
func (*System) ComputeBindVars ¶ added in v1.0.8
ComputeBindVars adds command to the default system CmdPool command buffer, to bind the Vars descriptors, for given collection of descriptors descIdx (see Vars NDescs for info). Required whenever variables have changed their mappings, before running a command.
func (*System) ComputeResetBegin ¶ added in v1.0.8
func (sy *System) ComputeResetBegin()
ComputeResetBegin resets and begins the recording of commands on the default system CmdPool -- use prior to ComputeCommand if not needing to call ComputeBindVars
func (*System) ComputeSubmit ¶ added in v1.0.8
func (sy *System) ComputeSubmit()
ComputeSubmit submits the current set of commands in the default system CmdPool, typically from ComputeCommand. does NOT wait for the commands to finish before returning control to the CPU. Can call this multiple times to run the same command iteratively, followed by a final wait, for example.
func (*System) ComputeSubmitWait ¶ added in v1.0.8
func (sy *System) ComputeSubmitWait()
ComputeSubmitWait submits the current set of commands in the default system CmdPool, typically from ComputeCommand. and then waits for the commands to finish before returning control to the CPU. Results will be available immediately thereafter for retrieving back fro the GPU.
func (*System) ComputeWait ¶ added in v1.0.8
func (sy *System) ComputeWait()
ComputeWait waits for previously-submitted commands to finish. Results will be available immediately thereafter for retrieving back fro the GPU.
func (*System) Config ¶
func (sy *System) Config()
Config configures the entire system, after everything has been setup (Pipelines, Vars, etc). Memory / Vals do not yet need to be configured and are not Config'd by this call.
func (*System) ConfigRender ¶
func (sy *System) ConfigRender(imgFmt *ImageFormat, depthFmt Types)
ConfigRender configures the renderpass, including the image format that we're rendering to, for a surface render target, and the depth buffer format (pass UndefType for no depth buffer).
func (*System) ConfigRenderNonSurface ¶
func (sy *System) ConfigRenderNonSurface(imgFmt *ImageFormat, depthFmt Types)
ConfigRenderNonSurface configures the renderpass, including the image format that we're rendering to, for a RenderFrame non-surface target, and the depth buffer format (pass UndefType for no depth buffer).
func (*System) EndRenderPass ¶
func (sy *System) EndRenderPass(cmd vk.CommandBuffer)
EndRenderPass adds commands to the given command buffer to end the render pass. It does not call EndCommandBuffer, in case any further commands are to be added.
func (*System) InitCmd ¶
func (sy *System) InitCmd()
InitCmd initializes the command pool and buffer
func (*System) InitCompute ¶
InitCompute initializes the System for compute functionality, which creates its own Compute device.
func (*System) InitGraphics ¶
InitGraphics initializes the System for graphics use, using the graphics device from the Surface associated with this system or another device can be initialized by calling sy.Device.Init(gp, vk.QueueGraphicsBit)
func (*System) MemCmdStart ¶
func (sy *System) MemCmdStart() vk.CommandBuffer
MemCmdStart starts a one-time memory command using the Memory CmdPool and Device associated with this System Use this for other random memory transfer commands.
func (*System) MemCmdSubmitWaitFree ¶
func (sy *System) MemCmdSubmitWaitFree()
MemCmdSubmitWaitFree submits current one-time memory command using the Memory CmdPool and Device associated with this System Use this for other random memory transfer commands.
func (*System) NewPipeline ¶
NewPipeline returns a new pipeline added to this System, initialized for use in this system.
func (*System) ResetBeginRenderPass ¶
func (sy *System) ResetBeginRenderPass(cmd vk.CommandBuffer, fr *Framebuffer, descIdx int)
ResetBeginRenderPass adds commands to the given command buffer to reset command buffer and call begin on it, then starts the render pass on given framebuffer (BeginRenderPass) Clears the frame first, according to the ClearVals. Also Binds descriptor sets to command buffer for given collection of descriptors descIdx (see Vars NDescs for info).
func (*System) ResetBeginRenderPassNoClear ¶
func (sy *System) ResetBeginRenderPassNoClear(cmd vk.CommandBuffer, fr *Framebuffer, descIdx int)
ResetBeginRenderPassNoClear adds commands to the given command buffer to reset command buffer and call begin on it, then starts the render pass on given framebuffer (BeginRenderPass) does NOT clear the frame first -- loads prior state. Also Binds descriptor sets to command buffer for given collection of descriptors descIdx (see Vars NDescs for info).
func (*System) SetClearColor ¶
SetClearColor sets the RGBA colors to set when starting new render For all pipelines, to keep graphics settings consistent.
func (*System) SetClearDepthStencil ¶
SetClearDepthStencil sets the depth and stencil values when starting new render For all pipelines, to keep graphics settings consistent.
func (*System) SetColorBlend ¶
SetColorBlend determines the color blending function: either 1-source alpha (alphaBlend) or no blending: new color overwrites old. Default is alphaBlend = true For all pipelines, to keep graphics settings consistent.
func (*System) SetCullFace ¶
SetCullFace sets the face culling mode: true = back, false = front use CullBack, CullFront constants
func (*System) SetFrontFace ¶
SetFrontFace sets the winding order for what counts as a front face true = CCW, false = CW
func (*System) SetGraphicsDefaults ¶
func (sy *System) SetGraphicsDefaults()
SetGraphicsDefaults configures all the default settings for all graphics rendering pipelines (not for a compute pipeline)
func (*System) SetLineWidth ¶
SetLineWidth sets the rendering line width -- 1 is default.
func (*System) SetRasterization ¶
func (sy *System) SetRasterization(polygonMode vk.PolygonMode, cullMode vk.CullModeFlagBits, frontFace vk.FrontFace, lineWidth float32)
SetRasterization sets various options for how to rasterize shapes: Defaults are: vk.PolygonModeFill, vk.CullModeBackBit, vk.FrontFaceCounterClockwise, 1.0 For all pipelines, to keep graphics settings consistent.
func (*System) SetTopology ¶
func (sy *System) SetTopology(topo Topologies, restartEnable bool)
SetTopology sets the topology of vertex position data. TriangleList is the default. Also for Strip modes, restartEnable allows restarting a new strip by inserting a ?? For all pipelines, to keep graphics settings consistent.
type Texture ¶
Texture supplies an Image and a Sampler
func (*Texture) AllocTexture ¶
func (tx *Texture) AllocTexture()
AllocTexture allocates texture device image, stdview, and sampler
type Topologies ¶
type Topologies int32
Topologies are the different vertex topology
func (*Topologies) FromString ¶
func (i *Topologies) FromString(s string) error
func (Topologies) String ¶
func (i Topologies) String() string
type Types ¶
type Types int32
Types is a list of supported GPU data types, which can be stored properly aligned in device memory, and used by the shader code. Note that a Vec3 or arrays of single scalar values such as Float32 are not well supported outside of Vertex due to the std410 convention: http://www.opengl.org/registry/doc/glspec45.core.pdf#page=159 The Struct type is particularly challenging as each member must be aligned in general on a 16 byte boundary (i.e., vec4) (unless all elements are exactly 4 bytes, which might work?). Go automatically aligns members to 8 bytes on 64 bit machines, but that doesn't quite cut it.
const ( UndefType Types = iota Bool32 Int16 Uint16 Int32 Int32Vec2 Int32Vec4 Uint32 Uint32Vec2 Uint32Vec4 Float32 Float32Vec2 Float32Vec3 // note: only use for vertex data -- not properly aligned for uniforms Float32Vec4 Float64 Float64Vec2 Float64Vec3 Float64Vec4 Float32Mat4 // std xform matrix: mat32.Mat4 works directly Float32Mat3 // std xform matrix: mat32.Mat3 works directly ImageRGBA32 // 32 bits with 8 bits per component of R,G,B,A -- std image format Depth32 // standard float32 depth buffer Depth24Sten8 // standard 24 bit float with 8 bit stencil Struct TypesN )
func (*Types) FromString ¶
func (Types) VkIndexType ¶
VkIndexType returns the Vulkan vk.IndexType for var must be either Uint16 or Uint32
type Val ¶
type Val struct { Name string `desc:"name of this value, named by default as the variable name_idx"` Idx int `desc:"index of this value within the Var list of values"` N int `` /* 146-byte string literal not displayed */ Offset int `desc:"offset in bytes from start of memory buffer"` Flags int32 `desc:"val state flags"` ElSize int `` /* 234-byte string literal not displayed */ AllocSize int `` /* 145-byte string literal not displayed */ Texture *Texture `desc:"for Texture Var roles, this is the Texture"` MemPtr unsafe.Pointer `view:"-" desc:"pointer to the start of the staging memory for this value"` }
Val represents a specific value of a Var variable.
func (*Val) AllocHost ¶
AllocHost allocates this value at given offset in owning Memory buffer. Computes the MemPtr for this item, and returns AllocSize() of this value, so memory can increment to next item. offsets are guaranteed to be properly aligned per minUniformBufferOffsetAlignment.
func (*Val) Bytes ¶
Bytes returns byte array of the Val data, including any additional alignment -- can be written to directly. Be mindful of potential padding and alignment issues relative to go-based storage. Set Mod flag when changes have been made.
func (*Val) CopyFromBytes ¶ added in v1.0.6
CopyFromBytes copies bytes from given source pointer into memory, and sets Mod flag. Use this for struct data types.
func (*Val) CopyToBytes ¶ added in v1.0.6
CopyToBytes copies bytes from val to given source pointer into memory. Use this for struct data types to retrieve computed results.
func (*Val) Floats32 ¶
Floats32 returns mat32.ArrayF32 of the Val data -- can be written to directly. Only recommended for Vertex data. Otherwise, be mindful of potential padding and alignment issues relative to go-based storage. Set Mod flag when changes have been made.
func (*Val) Init ¶
Init initializes value based on variable and index within list of vals for this var
func (*Val) PaddedArrayCheck ¶
PaddedArrayCheck checks if this is an array with padding on the elements due to alignment issues. If this is the case, then direct copying is not possible.
func (*Val) SetGoImage ¶
SetGoImage sets Texture image data from an *image.RGBA standard Go image, at given layer, and sets the Mod flag, so it will be sync'd by Memory or if TextureOwns is set for the var, it allocates Host memory. This is most efficiently done using an image.RGBA, but other formats will be converted as necessary. If flipY is true then the Image Y axis is flipped when copying into the image data (requires row-by-row copy) -- can avoid this by configuring texture coordinates to compensate.
type ValFlags ¶
type ValFlags int32
ValFlags are bitflags for Val state
const ( // ValMod the value has been modified ValMod ValFlags = iota // ValPaddedArray array had to be padded -- cannot access elements continuously ValPaddedArray // ValTextureOwns val owns and manages the host staging memory for texture. // based on Var TextureOwns -- for dynamically changings images. ValTextureOwns ValFlagsN )
func (*ValFlags) FromString ¶
type Vals ¶
type Vals struct { Vals []*Val `desc:"values in indexed order"` NameMap map[string]*Val `desc:"map of vals by name -- only for specifically named vals vs. generically allocated ones -- names must be unique"` TexSzAlloc szalloc.SzAlloc `` /* 318-byte string literal not displayed */ GpTexVals []*Val `` /* 157-byte string literal not displayed */ }
Vals is a list container of Val values, accessed by index or name
func (*Vals) ActiveVals ¶ added in v1.0.0
ActiveVals returns the Vals to actually use for memory allocation etc this is Vals list except for textures with TexSzAlloc.On active
func (*Vals) AllocHost ¶
AllocHost allocates values at given offset in given Memory buffer. Computes the MemPtr for each item, and returns TotSize across all vals. The effective offset increment (based on size) is aligned at the given align byte level, which should be MinUniformBufferOffsetAlignment from gpu.
func (*Vals) AllocTexBySize ¶ added in v1.0.0
AllocTexBySize allocates textures by size so they fit within the MaxTexturesPerGroup. Must call ConfigGoImage on the original values to set the sizes prior to calling this, and cannot have the TextureOwns flag set. Also does not support arrays in source vals. Apps can always use szalloc.SzAlloc upstream of this to allocate. This method creates actual image vals in GpTexVals, which are allocated. Must call SetGoImage on Vals here, which redirects to the proper allocated GpTexVals image and layer.
func (*Vals) AllocTextures ¶
AllocTextures allocates images on device memory only called on Role = TextureRole
func (*Vals) ConfigVals ¶
ConfigVals configures given number of values in the list for given variable. If the same number of vals is given, nothing is done, so it is safe to call repeatedly. Otherwise, any existing vals will be deleted -- the Memory system must free all associated memory prior! Returns true if new config made, else false if same size.
func (*Vals) Destroy ¶
func (vs *Vals) Destroy()
Destroy frees all existing values and resets the list of Vals so subsequent Config will start fresh (e.g., if Var type changes).
func (*Vals) Free ¶
func (vs *Vals) Free()
Free resets the MemPtr for values, resets any self-owned resources (Textures)
func (*Vals) SetGoImage ¶ added in v1.0.0
SetGoImage calls SetGoImage on the proper Texture value for given index. if TexSzAlloc.On via AllocTexBySize then this is routed to the actual allocated image array, otherwise it goes directly to the standard Val.
SetGoImage sets staging image data from a standard Go image at given layer. This is most efficiently done using an image.RGBA, but other formats will be converted as necessary. If flipY is true then the Image Y axis is flipped when copying into the image data, so that images will appear upright in the standard OpenGL Y-is-up coordinate system. If using the Y-is-down Vulkan coordinate system, don't flip. Only works if IsHostActive and Image Format is default vk.FormatR8g8b8a8Srgb, Must still call AllocImage to have image allocated on the device, and copy from this host staging data to the device.
func (*Vals) SetName ¶
SetName sets name of given Val, by index, adds name to map, checking that it is not already there yet. Returns val.
func (*Vals) ValByIdxTry ¶
ValByIdxTry returns Val at given index with range checking error message.
type Var ¶
type Var struct { Name string `desc:"variable name"` Type Types `` /* 433-byte string literal not displayed */ ArrayN int `` /* 217-byte string literal not displayed */ Role VarRoles `` /* 368-byte string literal not displayed */ Shaders vk.ShaderStageFlagBits `desc:"bit flags for set of shaders that this variable is used in"` Set int `` /* 139-byte string literal not displayed */ BindLoc int `` /* 188-byte string literal not displayed */ SizeOf int `` /* 245-byte string literal not displayed */ TextureOwns bool `` /* 180-byte string literal not displayed */ DynOffIdx int `` /* 149-byte string literal not displayed */ Vals Vals `` /* 298-byte string literal not displayed */ BindValIdx []int `` /* 354-byte string literal not displayed */ Offset int `desc:"offset -- only for push constants"` }
Var specifies a variable used in a pipeline, accessed in shader programs. A Var represents a type of input or output into the GPU program, including things like Vertex arrays, transformation matricies (Uniforms), Images (Textures), and arbitrary Structs for Compute shaders. Each Var belongs to a Set, and its binding location is allocated within that. Each set is updated at the same time scale, and all vars in the set have the same number of allocated Val instances representing a specific value of the variable. There must be a unique Val instance for each value of the variable used in a single render -- a previously-used Val's contents cannot be updated within the render pass, but new information can be written to an as-yet unused Val prior to using in a render (although this comes at a performance cost).
func (*Var) AllocHost ¶
AllocHost allocates values at given offset in given Memory buffer. Computes the MemPtr for each item, and returns TotSize across all vals. The effective offset increment (based on size) is aligned at the given align byte level, which should be MinUniformBufferOffsetAlignment from gpu.
func (*Var) AllocTextures ¶
AllocTextures allocates images on device memory only called on Role = TextureRole
func (*Var) BindVal ¶
BindVal returns the currently bound value at given descriptor collection index as set by BindDyn* methods. Returns nil, error if not valid.
func (*Var) Free ¶
func (vr *Var) Free()
Free resets the MemPtr for values, resets any self-owned resources (Textures)
func (*Var) Init ¶
func (vr *Var) Init(name string, typ Types, arrayN int, role VarRoles, set int, shaders ...ShaderTypes)
Init initializes the main values
func (*Var) SetTextureDev ¶
SetTextureDev sets Device for textures only called on Role = TextureRole
func (*Var) TextureValidIdx ¶
TextureValidIdx returns the index of the given texture value at our index in list of vals, starting at given index, skipping over any inactive textures which do not show up when accessed in the shader. You must use this value when passing a texture index to the shader! returns -1 if idx is not valid
func (*Var) ValsMemSize ¶
ValsMemSize returns the memory allocation size for all values for this Var, in bytes
type VarList ¶
type VarList struct { Vars []*Var `desc:"variables in order"` VarMap map[string]*Var `desc:"map of vars by name -- names must be unique"` }
VarList is a list of variables
func (*VarList) ValByIdxTry ¶
ValByIdxTry returns value by first looking up variable name, then value index, returning error if not found
func (*VarList) ValByNameTry ¶
ValByNameTry returns value by first looking up variable name, then value name, returning error if not found
type VarRoles ¶
type VarRoles int32
VarRoles are the functional roles of variables, corresponding to Vertex input vectors and all the different "uniform" types as enumerated in vk.DescriptorType. This does NOT map directly to DescriptorType because we combine vertex and uniform data and require a different ordering.
const ( UndefVarRole VarRoles = iota Vertex // vertex shader input data: mesh geometry points, normals, etc. These are automatically located in a separate Set, VertexSet (-2), and managed separately. Index // for indexed access to Vertex data, also located in VertexSet (-2) -- only one such Var per VarSet should be present -- will automatically be used if a dynamically bound val is set Push // for push constants, which have a minimum of 128 bytes and are stored directly in the command buffer -- they do not require any host-device synchronization or buffering, and are fully dynamic. They are ideal for transformation matricies or indexes for accessing data. They are stored in a special PushSet (-1) and managed separately. Uniform // read-only general purpose data, uses UniformBufferDynamic with offset specified at binding time, not during initial configuration -- compared to Storage, Uniform items can be put in local cache for each shader and thus can be much faster to access -- use for a smaller number of parameters such as transformation matricies Storage // read-write general purpose data, in StorageBufferDynamic (offset set at binding) -- this is a larger but slower pool of memory, with more flexible alignment constraints, used primarily for compute data UniformTexel // read-only image-formatted data, which cannot be accessed via ImageView or Sampler -- only for rare cases where optimized image format (e.g., rgb values of specific bit count) is useful. No Dynamic mode is available, so this can only be used for a fixed Val. StorageTexel // read-write image-formatted data, which cannot be accessed via ImageView or Sampler -- only for rare cases where optimized image format (e.g., rgb values of specific bit count) is useful. No Dynamic mode is available, so this can only be used for a fixed Val. StorageImage // read-write access through an ImageView (but not a Sampler) of an Image TextureRole // a Texture is a CombinedImageSampler in Vulkan terminology -- a combination of a Sampler and a specific Image, which appears as a single entity in the shader. VarRolesN )
func (*VarRoles) FromString ¶
func (VarRoles) VkDescriptor ¶
func (vr VarRoles) VkDescriptor() vk.DescriptorType
VkDescriptor returns the vk.DescriptorType
type VarSet ¶
type VarSet struct { VarList Set int `desc:"set number"` NValsPer int `` /* 586-byte string literal not displayed */ NTextureDescs int `` /* 273-byte string literal not displayed */ RoleMap map[VarRoles][]*Var `desc:"map of vars by different roles, within this set -- updated in Config(), after all vars added"` ParentVars *Vars `desc:"the parent vars we belong to"` VkLayout vk.DescriptorSetLayout `desc:"set layout info -- static description of each var type, role, binding, stages"` VkDescSets []vk.DescriptorSet `` /* 210-byte string literal not displayed */ }
VarSet contains a set of Var variables that are all updated at the same time and have the same number of distinct Vals values per Var per render pass. The first set at index -1 contains Vertex and Index data, handed separately.
func (*VarSet) Add ¶
func (st *VarSet) Add(name string, typ Types, arrayN int, role VarRoles, shaders ...ShaderTypes) *Var
Add adds a new variable of given type, role, arrayN, and shaders where used
func (*VarSet) AddStruct ¶
func (st *VarSet) AddStruct(name string, size int, arrayN int, role VarRoles, shaders ...ShaderTypes) *Var
AddStruct adds a new struct variable of given total number of bytes in size, type, role, set, and shaders where used
func (*VarSet) BindDynVal ¶
BindDynVal dynamically binds given uniform or storage value for given variable in given set.
This only dynamically updates the offset to point to the specified val. MUST call System.BindVars prior to any subsequent draw calls for this new offset to be bound at the proper point in the command buffer prior (call after all such dynamic bindings are updated.)
Do NOT call BindValsStart / End around this.
returns error if not found.
func (*VarSet) BindDynValIdx ¶
BindDynValIdx dynamically binds given uniform or storage value by index for given variable name, in given set.
This only dynamically updates the offset to point to the specified val. MUST call System.BindVars prior to any subsequent draw calls for this new offset to be bound at the proper point in the command buffer prior (call after all such dynamic bindings are updated.)
Do NOT call BindValsStart / End around this.
returns error if not found.
func (*VarSet) BindDynValName ¶
BindDynValName dynamically binds given uniform or storage value by name for given variable name, in given set.
This only dynamically updates the offset to point to the specified val. MUST call System.BindVars prior to any subsequent draw calls for this new offset to be bound at the proper point in the command buffer prior (call after all such dynamic bindings are updated.)
Do NOT call BindValsStart / End around this.
returns error if not found.
func (*VarSet) BindDynVar ¶
BindDynVar binds dynamic variable for given var for Uniform, Storage variables.
All vals must be uploaded to Device memory prior to this, and it is not possible to update actual values during a render pass. The memory buffer is essentially what is bound here.
Must have called BindVarsStart prior to this.
func (*VarSet) BindDynVarName ¶
BindDynVarName binds dynamic variable for given var looked up by name, for Uniform, Storage variables.
All vals must be uploaded to Device memory prior to this, and it is not possible to update actual values during a render pass. The memory buffer is essentially what is bound here.
Must have called BindVarsStart prior to this.
func (*VarSet) BindDynVars ¶
BindDynVars binds all dynamic vars in set, to be able to use dynamic vars, in subsequent BindDynVal* calls during the render pass, which update the offsets. For Uniform & Storage variables, which use dynamic binding.
All vals must be uploaded to Device memory prior to this, and it is not possible to update actual values during a render pass. The memory buffer is essentially what is bound here.
Must have called BindVarsStart prior to this.
func (*VarSet) BindStatVar ¶
BindStatVar does static variable binding for given var, For non-Uniform, Storage, variables (e.g., Textures). Each Val for a given Var is given a descriptor binding and the shader sees an array of values of corresponding length. All vals must be uploaded to Device memory prior to this, and it is not possible to update anything during a render pass.
func (*VarSet) BindStatVarName ¶
BindStatVarName does static variable binding for given var looked up by name, For non-Uniform, Storage, variables (e.g., Textures). Each Val for a given Var is given a descriptor binding and the shader sees an array of values of corresponding length. All vals must be uploaded to Device memory prior to this, and it is not possible to update anything during a render pass.
func (*VarSet) BindStatVars ¶
BindStatVars binds all static vars to their current values, for non-Uniform, Storage, variables (e.g., Textures). Each Val for a given Var is given a descriptor binding and the shader sees an array of values of corresponding length. All vals must be uploaded to Device memory prior to this, and it is not possible to update anything during a render pass.
func (*VarSet) Config ¶
Config must be called after all variables have been added. configures binding / location for all vars based on sequential order. also does validation and returns error message.
func (*VarSet) ConfigVals ¶
ConfigVals configures the Vals for the vars in this set, allocating nvals per variable. There must be a unique value available for each distinct value to be rendered within a single pass. All Vars in the same set have the same number of vals. Any existing vals will be deleted -- must free all associated memory prior!
func (*VarSet) DescLayout ¶
DescLayout creates the DescriptorSetLayout in DescLayout for given set. Only for non-VertexSet sets. Must have set NValsPer for any TextureRole vars, which require separate descriptors per.
func (*VarSet) Destroy ¶
Destroy destroys infrastructure for Set, Vars and Vals -- assumes Free has already been called to free host and device memory.
func (*VarSet) DestroyLayout ¶
DestroyLayout destroys layout
func (*VarSet) TexGpSzIdxs ¶ added in v1.0.0
TexGpSzIdxs for texture at given index, allocated in groups by size using Vals.AllocTexBySize, returns the indexes for the texture and layer to actually select the texture in the shader, and proportion of the Gp allocated texture size occupied by the texture.
func (*VarSet) VkPushConfig ¶
func (vs *VarSet) VkPushConfig() []vk.PushConstantRange
VkPushConfig returns vulkan push constant ranges
func (*VarSet) VkVertexConfig ¶
func (st *VarSet) VkVertexConfig() *vk.PipelineVertexInputStateCreateInfo
VkVertexConfig fills in the relevant info into given vulkan config struct. for VertexSet only! Note: there is no support for interleaved arrays so each binding and location is assigned the same sequential number, recorded in var BindLoc
type Vars ¶
type Vars struct { SetMap map[int]*VarSet `desc:"map of sets, by set number -- VertexSet is -2, PushSet is -1, rest are added incrementally"` RoleMap map[VarRoles][]*Var `` /* 142-byte string literal not displayed */ HasVertex bool `inactive:"+" desc:"true if a VertexSet has been added"` HasPush bool `inactive:"+" desc:"true if PushSet has been added"` NDescs int `` /* 442-byte string literal not displayed */ Mem *Memory `view:"-" desc:"our parent memory manager"` VkDescLayout vk.PipelineLayout `view:"-" desc:"vulkan descriptor layout based on vars"` VkDescPool vk.DescriptorPool `view:"-" desc:"vulkan descriptor pool, allocated for NDescs and the different descriptor pools"` VkDescSets [][]vk.DescriptorSet `` /* 372-byte string literal not displayed */ VkWriteVals []vk.WriteDescriptorSet `` /* 133-byte string literal not displayed */ BindDescIdx int `inactive:"-" desc:"current descriptor collection index, set in BindValsStart"` DynOffs [][]uint32 `` /* 273-byte string literal not displayed */ }
Vars are all the variables that are used by a pipeline, organized into Sets (optionally including the special VertexSet or PushSet). Vars are allocated to bindings / locations sequentially in the order added!
func (*Vars) AddDynOff ¶
func (vs *Vars) AddDynOff()
AddDynOff adds one more dynamic offset across all NDescs
func (*Vars) AddPushSet ¶
AddPushSet adds a new push constant Set -- this is a special Set holding values sent directly in the command buffer.
func (*Vars) AddSet ¶
AddSet adds a new non-Vertex Set for holding Uniforms, Storage, etc Sets are automatically numbered sequentially
func (*Vars) AddVertexSet ¶
AddVertexSet adds a new Vertex Set -- this is a special Set holding Vertex, Index vars
func (*Vars) AllocTextures ¶
AllocTextures allocates images on device memory
func (*Vars) BindAllTextureVars ¶
BindAllTextureVars binds all Texture vars in given set to their current values, iterating over NTextureDescs in case there are multiple Desc sets required to represent more than MaxTexturesPerSet. Each Val for a given Var is given a descriptor binding and the shader sees an array of values of corresponding length. All vals must be uploaded to Device memory prior to this, and it is not possible to update anything during a render pass. This calls BindStart / Bind
func (*Vars) BindDynVal ¶
BindDynVal dynamically binds given uniform or storage value for given variable in given set.
This only dynamically updates the offset to point to the specified val. MUST call System.BindVars prior to any subsequent draw calls for this new offset to be bound at the proper point in the command buffer prior (call after all such dynamic bindings are updated.)
Do NOT call BindValsStart / End around this.
returns error if not found.
func (*Vars) BindDynValIdx ¶
BindDynValIdx dynamically binds given uniform or storage value by index for given variable name, in given set.
This only dynamically updates the offset to point to the specified val. MUST call System.BindVars prior to any subsequent draw calls for this new offset to be bound at the proper point in the command buffer prior (call after all such dynamic bindings are updated.)
Do NOT call BindValsStart / End around this.
returns error if not found.
func (*Vars) BindDynValName ¶
BindDynValName dynamically binds given uniform or storage value by name for given variable name, in given set.
This only dynamically updates the offset to point to the specified val. MUST call System.BindVars prior to any subsequent draw calls for this new offset to be bound at the proper point in the command buffer prior (call after all such dynamic bindings are updated.)
Do NOT call BindValsStart / End around this.
returns error if not found.
func (*Vars) BindDynVarName ¶
BindDynVarName binds dynamic variable for given var looked up by name, for Uniform, Storage variables.
All vals must be uploaded to Device memory prior to this, and it is not possible to update actual values during a render pass. The memory buffer is essentially what is bound here.
Must have called BindVarsStart prior to this.
func (*Vars) BindDynVars ¶
BindDynVars binds all dynamic vars in given set, to be able to use dynamic vars, in subsequent BindDynVal* calls during the render pass, which update the offsets. For Uniform & Storage variables, which use dynamic binding.
This is automatically called during Config on the System, and usually does not need to be called again.
All vals must be uploaded to Device memory prior to this, and it is not possible to update actual values during a render pass. The memory buffer is essentially what is bound here.
Must have called BindVarsStart prior to this.
func (*Vars) BindDynVarsAll ¶
func (vs *Vars) BindDynVarsAll()
BindDynVarsAll binds all dynamic vars across all sets. Called during system config.
func (*Vars) BindStatVarName ¶
BindStatVarName does static variable binding for given var looked up by name, for non-Uniform, Storage, variables (e.g., Textures). Each Val for a given Var is given a descriptor binding and the shader sees an array of values of corresponding length.
All vals must be uploaded to Device memory prior to this, and it is not possible to update anything during a render pass.
Must have called BindVarsStart prior to this.
func (*Vars) BindStatVars ¶
BindStatVars binds all static vars to their current values, for given set, for non-Uniform, Storage, variables (e.g., Textures). Each Val for a given Var is given a descriptor binding and the shader sees an array of values of corresponding length.
All vals must be uploaded to Device memory prior to this, and it is not possible to update anything during a render pass.
Must have called BindVarsStart prior to this.
func (*Vars) BindVarsEnd ¶
func (vs *Vars) BindVarsEnd()
BindVarsEnd finishes a new step of binding started by BindVarsStart. Actually executes the binding updates, based on prior BindVar* calls.
func (*Vars) BindVarsStart ¶
BindVarsStart starts a new step of binding vars to descriptor sets, using given descIdx description set index (among the NDescs allocated). Bound vars determine what the shader programs see, in subsequent calls to Pipeline commands.
This must be called *prior* to a render pass, never within it. Only BindDyn* and BindVertex* calls can be called within render.
Do NOT use this around BindDynVal or BindVertexVal calls only for BindVar* methods.
Subsequent calls of BindVar* methods will add to a list, which will be executed when BindValsEnd is called.
This creates a set of entries in a list of WriteDescriptorSet's
func (*Vars) BindVertexValIdx ¶
BindVertexValIdx dynamically binds given VertexSet value by index for given variable name. using given descIdx description set index (among the NDescs allocated).
Value must have already been updated into device memory prior to this, ideally through a batch update prior to starting rendering, so that all the values are ready to be used during the render pass. This only dynamically updates the offset to point to the specified val.
Do NOT call BindValsStart / End around this.
returns error if not found.
func (*Vars) BindVertexValName ¶
BindVertexValName dynamically binds given VertexSet value by name for given variable name. using given descIdx description set index (among the NDescs allocated).
Value must have already been updated into device memory prior to this, ideally through a batch update prior to starting rendering, so that all the values are ready to be used during the render pass. This dynamically updates the offset to point to the specified val.
Do NOT call BindValsStart / End around this.
returns error if not found.
func (*Vars) Config ¶
Config must be called after all variables have been added. Configures all Sets and also does validation, returning error does DescLayout too, so all ready for Pipeline config.
func (*Vars) DescLayout ¶
DescLayout configures the PipelineLayout of DescriptorSetLayout info for all of the non-Vertex vars
func (*Vars) TexGpSzIdxs ¶ added in v1.0.0
TexGpSzIdxs for texture at given index, allocated in groups by size using Vals.AllocTexBySize, returns the indexes for the texture and layer to actually select the texture in the shader, and proportion of the Gp allocated texture size occupied by the texture.
func (*Vars) ValByIdxTry ¶
ValByIdxTry returns value by first looking up variable name, then value index, returning error if not found
func (*Vars) ValByNameTry ¶
ValByNameTry returns value by first looking up variable name, then value name, within given set number, returning error if not found
func (*Vars) VarByNameTry ¶
VarByNameTry returns Var by name in given set number, returning error if not found
func (*Vars) VertexSet ¶
VertexSet returns the Vertex Set -- a special Set holding Vertex, Index vars
func (*Vars) VkPushConfig ¶
func (vs *Vars) VkPushConfig() []vk.PushConstantRange
VkPushConfig returns vulkan push constant ranges, only if PushSet used.
func (*Vars) VkVertexConfig ¶
func (vs *Vars) VkVertexConfig() *vk.PipelineVertexInputStateCreateInfo
VkVertexConfig returns vulkan vertex config struct, for VertexSet only! Note: there is no support for interleaved arrays so each binding and location is assigned the same sequential number, recorded in var BindLoc
Source Files ¶
- bordercolors_string.go
- bufftypes_string.go
- cmds.go
- compute.go
- consts.go
- debug.go
- device.go
- errors.go
- framebuffer.go
- gpu.go
- gpu_linux.go
- image.go
- imageflags_string.go
- membuff.go
- memory.go
- pipeline.go
- render.go
- renderframe.go
- roles.go
- samplermodes_string.go
- shader.go
- strings.go
- surface.go
- system.go
- texture.go
- topologies_string.go
- types.go
- types_string.go
- valflags_string.go
- vals.go
- var.go
- varroles_string.go
- vars.go
- varset.go
- version.go