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 CleanString(s string) string
- func CmdBegin(cmd vk.CommandBuffer)
- func CmdBeginOneTime(cmd vk.CommandBuffer)
- func CmdEnd(cmd vk.CommandBuffer)
- func CmdEndSubmitWait(cmd vk.CommandBuffer, dev *Device)
- func CmdReset(cmd vk.CommandBuffer)
- func CmdResetBegin(cmd vk.CommandBuffer)
- func CmdSubmit(cmd vk.CommandBuffer, dev *Device)
- func CmdSubmitFence(cmd vk.CommandBuffer, dev *Device, fence vk.Fence)
- func CmdSubmitSignal(cmd vk.CommandBuffer, dev *Device, signal vk.Semaphore, fence vk.Fence)
- func CmdSubmitWait(cmd vk.CommandBuffer, dev *Device)
- func CmdSubmitWaitSignal(cmd vk.CommandBuffer, dev *Device, wait, signal vk.Semaphore, fence vk.Fence)
- 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 HasAllStrings(s string, strs []string) bool
- func IfPanic(err error, finalizers ...func())
- func ImageSRGBFmLinear(img *image.RGBA) *image.RGBA
- func ImageSRGBToLinear(img *image.RGBA) *image.RGBA
- func ImageToRGBA(img image.Image) *image.RGBA
- func ImgCompToUint8(val float32) uint8
- 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 NewEvent(dev vk.Device) vk.Event
- func NewFence(dev vk.Device) vk.Fence
- func NewSemaphore(dev vk.Device) vk.Semaphore
- func PlatformDefaults(gp *GPU)
- func SRGBFmLinear(rl, gl, bl float32) (r, g, b float32)
- func SRGBFmLinearComp(lin float32) float32
- func SRGBToLinear(r, g, b float32) (rl, gl, bl float32)
- func SRGBToLinearComp(srgb float32) float32
- 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)
- func Warps(n, threads int) int
- type BorderColors
- type BuffTypes
- type CPUOptions
- 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) EndSubmitWait(dev *Device)
- func (cp *CmdPool) EndSubmitWaitFree(dev *Device)
- 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)
- 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) CheckGPUOpts(feats *vk.PhysicalDeviceFeatures, opts *GPUOpts, report bool) bool
- func (gp *GPU) Config(name string, opts ...*GPUOpts) error
- func (gp *GPU) Defaults(graphics bool)
- func (gp *GPU) Destroy()
- func (gp *GPU) GetDeviceName(props *vk.PhysicalDeviceProperties, idx int) string
- 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
- func (gp *GPU) SetGPUOpts(feats *vk.PhysicalDeviceFeatures, opts GPUOpts)
- type GPUOpts
- 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) IsRGBAUnorm() bool
- func (im *ImageFormat) IsStdRGBA() bool
- func (im *ImageFormat) LayerByteSize() int
- func (im *ImageFormat) NSamples() 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) AllocHostStorageBuff()
- func (mm *Memory) CmdTransferRegsFmGPU(cmd vk.CommandBuffer, buff *MemBuff, regs []MemReg)
- func (mm *Memory) CmdTransferRegsToGPU(cmd vk.CommandBuffer, buff *MemBuff, regs []MemReg)
- func (mm *Memory) CmdTransferStorageBuffRegsFmGPU(cmd vk.CommandBuffer, buff *MemBuff, buffIdx int, regs []MemReg)
- func (mm *Memory) CmdTransferStorageBuffRegsToGPU(cmd vk.CommandBuffer, buff *MemBuff, buffIdx int, regs []MemReg)
- func (mm *Memory) CmdTransferStorageRegsFmGPU(cmd vk.CommandBuffer, regs []MemReg)
- func (mm *Memory) CmdTransferStorageRegsToGPU(cmd vk.CommandBuffer, regs []MemReg)
- 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) SyncRegionValIdx(set int, varNm string, valIdx int) (MemReg, error)
- func (mm *Memory) SyncRegionValName(set int, varNm, valNm string) (MemReg, error)
- func (mm *Memory) SyncStorageRegionsFmGPU(regs ...MemReg)
- func (mm *Memory) SyncToGPU()
- func (mm *Memory) SyncToGPUBuff(bt BuffTypes)
- 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(regs []MemReg)
- func (mm *Memory) TransferRegsToGPU(regs []MemReg)
- func (mm *Memory) TransferStorageRegsFmGPU(regs []MemReg)
- func (mm *Memory) TransferStorageRegsToGPU(regs []MemReg)
- func (mm *Memory) TransferTexturesToGPU(buff vk.Buffer, imgs ...*Image)
- func (mm *Memory) TransferToGPU()
- func (mm *Memory) TransferToGPUBuff(bt BuffTypes)
- type OptionStates
- 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) AddShaderEmbed(name string, typ ShaderTypes, efs embed.FS, fname string) *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) ComputeDispatch(cmd vk.CommandBuffer, nx, ny, nz int)
- func (pl *Pipeline) ComputeDispatch1D(cmd vk.CommandBuffer, n, threads 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) ConfigGrabDepth(dev vk.Device)
- func (rp *Render) ConfigImpl(dev vk.Device, imgFmt *ImageFormat, depthFmt Types, clear bool) vk.RenderPass
- func (rp *Render) DepthImageArray() ([]float32, error)
- func (rp *Render) Destroy()
- func (rp *Render) GrabDepthImage(dev vk.Device, cmd vk.CommandBuffer) error
- 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) GrabDepthImage(cmd vk.CommandBuffer)
- 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) CmdBuffByNameTry(name string) (vk.CommandBuffer, error)
- func (sy *System) CmdResetBindVars(cmd vk.CommandBuffer, descIdx int)
- func (sy *System) CmdSubmitWait()
- func (sy *System) ComputeCmdBuff() vk.CommandBuffer
- func (sy *System) ComputeCmdEnd(cmd vk.CommandBuffer)
- func (sy *System) ComputeCopyFmGPU(cmd vk.CommandBuffer, regs ...MemReg)
- func (sy *System) ComputeCopyToGPU(cmd vk.CommandBuffer, regs ...MemReg)
- func (sy *System) ComputeResetBegin(cmd vk.CommandBuffer)
- func (sy *System) ComputeResetBindVars(cmd vk.CommandBuffer, descIdx int)
- func (sy *System) ComputeSetEvent(cmd vk.CommandBuffer, event string) error
- func (sy *System) ComputeSubmitSignal(cmd vk.CommandBuffer, signal, fence string) error
- func (sy *System) ComputeSubmitWait(cmd vk.CommandBuffer)
- func (sy *System) ComputeSubmitWaitSignal(cmd vk.CommandBuffer, wait, signal, fence string) error
- func (sy *System) ComputeWait() error
- func (sy *System) ComputeWaitEvents(cmd vk.CommandBuffer, event ...string) error
- func (sy *System) ComputeWaitFence(fence string) error
- func (sy *System) ComputeWaitMemHostToShader(cmd vk.CommandBuffer)
- func (sy *System) ComputeWaitMemShaderToHost(cmd vk.CommandBuffer)
- func (sy *System) ComputeWaitMemWriteRead(cmd vk.CommandBuffer)
- func (sy *System) ComputeWaitMemoryBuff(cmd vk.CommandBuffer, buff *MemBuff)
- 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) EventByNameTry(name string) (vk.Event, error)
- func (sy *System) FenceByNameTry(name string) (vk.Fence, error)
- 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) MemCmdEndSubmitWaitFree()
- func (sy *System) MemCmdStart() vk.CommandBuffer
- func (sy *System) NewCmdBuff(name string) vk.CommandBuffer
- func (sy *System) NewComputePipelineEmbed(name string, efs embed.FS, fname string) *Pipeline
- func (sy *System) NewEvent(name string) vk.Event
- func (sy *System) NewFence(name string) vk.Fence
- func (sy *System) NewPipeline(name string) *Pipeline
- func (sy *System) NewSemaphore(name string) vk.Semaphore
- func (sy *System) PipelineByNameTry(name string) (*Pipeline, error)
- 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) SemaphoreByNameTry(name string) (vk.Semaphore, error)
- 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(vr *Var) 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(vr *Var) []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) MemSizeStorage(mm *Memory, alignBytes 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 VarMem
- 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) BindDynValsAllIdx(vs *Vars, idx int)
- 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) BindStatVarsAll(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) BindDynValsAllIdx(idx int)
- 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) BindStatVarsAll()
- 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) MemSizeStorage(mm *Memory, alignBytes int)
- func (vs *Vars) ModRegs(bt BuffTypes) []MemReg
- func (vs *Vars) ModRegsStorage(bufIdx int, buff *MemBuff) []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.34" GitCommit = "df0c7de" // the commit JUST BEFORE the release VersionDate = "2023-09-25 05:40" // UTC )
const ByteCopyMemoryLimit int = 0x7fffffffffff
ByteCopyMemoryLimit represents the total number of bytes that can be copied from a Vulkan Memory Buffer to a byte slice.
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.FormatR8g8b8a8Unorm: 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_CPUOptions = kit.Enums.AddEnum(OptionStatesN, kit.NotBitFlag, nil)
var KiT_ImageFlags = kit.Enums.AddEnum(ImageFlagsN, kit.BitFlag, nil)
var KiT_OptionStates = kit.Enums.AddEnum(OptionStatesN, kit.NotBitFlag, 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 StaticRoleDescriptors = map[VarRoles]vk.DescriptorType{ Uniform: vk.DescriptorTypeUniformBuffer, Storage: vk.DescriptorTypeStorageBuffer, UniformTexel: vk.DescriptorTypeUniformTexelBuffer, StorageTexel: vk.DescriptorTypeStorageTexelBuffer, StorageImage: vk.DescriptorTypeStorageImage, TextureRole: vk.DescriptorTypeCombinedImageSampler, }
For static variable binding
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 CleanString ¶ added in v1.0.31
func CmdBeginOneTime ¶
func CmdBeginOneTime(cmd vk.CommandBuffer)
CmdBeginOneTime does BeginCommandBuffer with OneTimeSubmit set on buffer
func CmdEndSubmitWait ¶ added in v1.0.10
func CmdEndSubmitWait(cmd vk.CommandBuffer, dev *Device)
CmdEndSubmitWait does End, Submit, WaitIdle on command 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 CmdSubmitFence ¶ added in v1.0.20
func CmdSubmitFence(cmd vk.CommandBuffer, dev *Device, fence vk.Fence)
CmdSubmitFence submits commands in buffer to given device queue using given fence.
func CmdSubmitSignal ¶ added in v1.0.16
CmdSubmitSignal submits command in buffer to given device queue with given signal semaphore when done, and with given fence (use vk.NullFence for none). The optional fence is used typically at the end of a block of such commands, whenever the CPU needs to be sure the submitted GPU commands have completed.
func CmdSubmitWait ¶
func CmdSubmitWait(cmd vk.CommandBuffer, dev *Device)
CmdSubmitWait does Submit, WaitIdle on command Buffer
func CmdSubmitWaitSignal ¶ added in v1.0.16
func CmdSubmitWaitSignal(cmd vk.CommandBuffer, dev *Device, wait, signal vk.Semaphore, fence vk.Fence)
CmdSubmitWaitSignal submits command in buffer to given device queue with given wait semaphore and given signal semaphore when done, and with given fence (use vk.NullFence for none). This will cause the GPU to wait until the wait semphaphore is signaled by a previous command with that semaphore as its signal. The optional fence is used typically at the end of a block of such commands, whenever the CPU needs to be sure the submitted GPU commands have completed.
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 HasAllStrings ¶ added in v1.0.31
func ImageSRGBFmLinear ¶ added in v1.0.22
ImageSRGBFmLinear returns a sRGB colorspace version of given linear colorspace image
func ImageSRGBToLinear ¶ added in v1.0.22
ImageSRGBToLinear returns a linear colorspace version of sRGB colorspace image
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 ImgCompToUint8 ¶ added in v1.0.22
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 NewEvent ¶ added in v1.0.19
New Event creates a new Event, setting the DeviceOnly bit flag because we typically only use events for within-device communication. and presumably this is faster if so-scoped.
func PlatformDefaults ¶ added in v1.0.0
func PlatformDefaults(gp *GPU)
func SRGBFmLinear ¶ added in v1.0.22
SRGBFmLinear converts set of sRGB components from linear values, adding gamma correction.
func SRGBFmLinearComp ¶ added in v1.0.22
SRGBFmLinearComp converts an sRGB rgb linear component to non-linear (gamma corrected) sRGB value Used in converting from XYZ to sRGB.
func SRGBToLinear ¶ added in v1.0.22
SRGBToLinear converts set of sRGB components to linear values, removing gamma correction.
func SRGBToLinearComp ¶ added in v1.0.22
SRGBToLinearComp converts an sRGB rgb component to linear space (removes gamma). Used in converting from sRGB to XYZ colors.
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 CPUOptions ¶ added in v1.0.27
type CPUOptions int
GPUOptions specifies supported options for the vgpu device upon initialization. Several vulkan device features are automatically enabled, which are required for the basic functionality of vgpu supported graphics, but these are optional and may be required for other uses (e.g., compute shaders). See also InstanceExts, DeviceExts, and ValidationLayers.
const ( // OptRobustBufferAccess specifies that accesses to buffers are bounds-checked against the range of the buffer descriptor (as determined by VkDescriptorBufferInfo::range, VkBufferViewCreateInfo::range, or the size of the buffer). Out of bounds accesses must not cause application termination, and the effects of shader loads, stores, and atomics must conform to an implementation-dependent behavior as described below. OptRobustBufferAccess CPUOptions = iota // OptFullDrawIndexUint32 specifies the full 32-bit range of indices is supported for indexed draw calls when using a VkIndexType of VK_INDEX_TYPE_UINT32. maxDrawIndexedIndexValue is the maximum index value that may be used (aside from the primitive restart index, which is always 232-1 when the VkIndexType is VK_INDEX_TYPE_UINT32). If this feature is supported, maxDrawIndexedIndexValue must be 232-1; otherwise it must be no smaller than 224-1. See maxDrawIndexedIndexValue. OptFullDrawIndexUint32 // OptImageCubeArray specifies whether image views with a VkImageViewType of VK_IMAGE_VIEW_TYPE_CUBE_ARRAY can be created, and that the corresponding SampledCubeArray and ImageCubeArray SPIR-V capabilities can be used in shader code. OptImageCubeArray // OptIndependentBlend specifies whether the VkPipelineColorBlendAttachmentState settings are controlled independently per-attachment. If this feature is not enabled, the VkPipelineColorBlendAttachmentState settings for all color attachments must be identical. Otherwise, a different VkPipelineColorBlendAttachmentState can be provided for each bound color attachment. OptIndependentBlend // OptGeometryShader specifies whether geometry shaders are supported. If this feature is not enabled, the VK_SHADER_STAGE_GEOMETRY_BIT and VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT enum values must not be used. This also specifies whether shader modules can declare the Geometry capability. OptGeometryShader // OptTessellationShader specifies whether tessellation control and evaluation shaders are supported. If this feature is not enabled, the VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT, VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT, and VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO enum values must not be used. This also specifies whether shader modules can declare the Tessellation capability. OptTessellationShader // OptSampleRateShading specifies whether Sample Shading and multisample interpolation are supported. If this feature is not enabled, the sampleShadingEnable member of the VkPipelineMultisampleStateCreateInfo structure must be set to VK_FALSE and the minSampleShading member is ignored. This also specifies whether shader modules can declare the SampleRateShading capability. OptSampleRateShading // OptDualSrcBlend specifies whether blend operations which take two sources are supported. If this feature is not enabled, the VK_BLEND_FACTOR_SRC1_COLOR, VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR, VK_BLEND_FACTOR_SRC1_ALPHA, and VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA enum values must not be used as source or destination blending factors. See https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#framebuffer-dsb. OptDualSrcBlend // OptLogicOp specifies whether logic operations are supported. If this feature is not enabled, the logicOpEnable member of the VkPipelineColorBlendStateCreateInfo structure must be set to VK_FALSE, and the logicOp member is ignored. OptLogicOp // OptMultiDrawIndirect specifies whether multiple draw indirect is supported. If this feature is not enabled, the drawCount parameter to the vkCmdDrawIndirect and vkCmdDrawIndexedIndirect commands must be 0 or 1. The maxDrawIndirectCount member of the VkPhysicalDeviceLimits structure must also be 1 if this feature is not supported. See maxDrawIndirectCount. OptMultiDrawIndirect // OptDrawIndirectFirstInstance specifies whether indirect drawing calls support the firstInstance parameter. If this feature is not enabled, the firstInstance member of all VkDrawIndirectCommand and VkDrawIndexedIndirectCommand structures that are provided to the vkCmdDrawIndirect and vkCmdDrawIndexedIndirect commands must be 0. OptDrawIndirectFirstInstance // OptDepthClamp specifies whether depth clamping is supported. If this feature is not enabled, the depthClampEnable member of the VkPipelineRasterizationStateCreateInfo structure must be set to VK_FALSE. Otherwise, setting depthClampEnable to VK_TRUE will enable depth clamping. OptDepthClamp // OptDepthBiasClamp specifies whether depth bias clamping is supported. If this feature is not enabled, the depthBiasClamp member of the VkPipelineRasterizationStateCreateInfo structure must be set to 0.0 unless the VK_DYNAMIC_STATE_DEPTH_BIAS dynamic state is enabled, and the depthBiasClamp parameter to vkCmdSetDepthBias must be set to 0.0. OptDepthBiasClamp // OptFillModeNonSolid specifies whether point and wireframe fill modes are supported. If this feature is not enabled, the VK_POLYGON_MODE_POINT and VK_POLYGON_MODE_LINE enum values must not be used. OptFillModeNonSolid // OptDepthBounds specifies whether depth bounds tests are supported. If this feature is not enabled, the depthBoundsTestEnable member of the VkPipelineDepthStencilStateCreateInfo structure must be set to VK_FALSE. When depthBoundsTestEnable is set to VK_FALSE, the minDepthBounds and maxDepthBounds members of the VkPipelineDepthStencilStateCreateInfo structure are ignored. OptDepthBounds // OptWideLines specifies whether lines with width other than 1.0 are supported. If this feature is not enabled, the lineWidth member of the VkPipelineRasterizationStateCreateInfo structure must be set to 1.0 unless the VK_DYNAMIC_STATE_LINE_WIDTH dynamic state is enabled, and the lineWidth parameter to vkCmdSetLineWidth must be set to 1.0. When this feature is supported, the range and granularity of supported line widths are indicated by the lineWidthRange and lineWidthGranularity members of the VkPhysicalDeviceLimits structure, respectively. OptWideLines // OptLargePoints specifies whether points with size greater than 1.0 are supported. If this feature is not enabled, only a point size of 1.0 written by a shader is supported. The range and granularity of supported point sizes are indicated by the pointSizeRange and pointSizeGranularity members of the VkPhysicalDeviceLimits structure, respectively. OptLargePoints // OptAlphaToOne specifies whether the implementation is able to replace the alpha value of the fragment shader color output in the Multisample Coverage fragment operation. If this feature is not enabled, then the alphaToOneEnable member of the VkPipelineMultisampleStateCreateInfo structure must be set to VK_FALSE. Otherwise setting alphaToOneEnable to VK_TRUE will enable alpha-to-one behavior. OptAlphaToOne // OptMultiViewport specifies whether more than one viewport is supported. If this feature is not enabled: The viewportCount and scissorCount members of the VkPipelineViewportStateCreateInfo structure must be set to 1. The firstViewport and viewportCount parameters to the vkCmdSetViewport command must be set to 0 and 1, respectively. The firstScissor and scissorCount parameters to the vkCmdSetScissor command must be set to 0 and 1, respectively. The exclusiveScissorCount member of the VkPipelineViewportExclusiveScissorStateCreateInfoNV structure must be set to 0 or 1. The firstExclusiveScissor and exclusiveScissorCount parameters to the vkCmdSetExclusiveScissorNV command must be set to 0 and 1, respectively. OptMultiViewport // OptSamplerAnisotropy specifies whether anisotropic filtering is supported. If this feature is not enabled, the anisotropyEnable member of the VkSamplerCreateInfo structure must be VK_FALSE. OptSamplerAnisotropy // OptTextureCompressionETC2 specifies whether all of the ETC2 and EAC compressed texture formats are supported. If this feature is enabled, then the VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT, VK_FORMAT_FEATURE_BLIT_SRC_BIT and VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT features must be supported in optimalTilingFeatures for various formats -- see the Vulkan Spec at https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceFeatures.html OptTextureCompressionETC2 // OptTextureCompressionASTC_LDR specifies whether all of the ASTC LDR compressed texture formats are supported. If this feature is enabled, then the VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT, VK_FORMAT_FEATURE_BLIT_SRC_BIT and VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT features must be supported in optimalTilingFeatures for various formats -- see the Vulkan Spec at https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceFeatures.html OptTextureCompressionASTC_LDR // OptTextureCompressionBC specifies whether all of the BC compressed texture formats are supported. If this feature is enabled, then the VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT, VK_FORMAT_FEATURE_BLIT_SRC_BIT and VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT features must be supported in optimalTilingFeatures for various formats -- see the Vulkan Spec at https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceFeatures.html OptTextureCompressionBC // OptOcclusionQueryPrecise specifies whether occlusion queries returning actual sample counts are supported. Occlusion queries are created in a VkQueryPool by specifying the queryType of VK_QUERY_TYPE_OCCLUSION in the VkQueryPoolCreateInfo structure which is passed to vkCreateQueryPool. If this feature is enabled, queries of this type can enable VK_QUERY_CONTROL_PRECISE_BIT in the flags parameter to vkCmdBeginQuery. If this feature is not supported, the implementation supports only boolean occlusion queries. When any samples are passed, boolean queries will return a non-zero result value, otherwise a result value of zero is returned. When this feature is enabled and VK_QUERY_CONTROL_PRECISE_BIT is set, occlusion queries will report the actual number of samples passed. OptOcclusionQueryPrecise // OptPipelineStatisticsQuery specifies whether the pipeline statistics queries are supported. If this feature is not enabled, queries of type VK_QUERY_TYPE_PIPELINE_STATISTICS cannot be created, and none of the VkQueryPipelineStatisticFlagBits bits can be set in the pipelineStatistics member of the VkQueryPoolCreateInfo structure. OptPipelineStatisticsQuery // OptVertexPipelineStoresAndAtomics specifies whether storage buffers and images support stores and atomic operations in the vertex, tessellation, and geometry shader stages. If this feature is not enabled, all storage image, storage texel buffer, and storage buffer variables used by these stages in shader modules must be decorated with the NonWritable decoration (or the readonly memory qualifier in GLSL). OptVertexPipelineStoresAndAtomics // OptFragmentStoresAndAtomics specifies whether storage buffers and images support stores and atomic operations in the fragment shader stage. If this feature is not enabled, all storage image, storage texel buffer, and storage buffer variables used by the fragment stage in shader modules must be decorated with the NonWritable decoration (or the readonly memory qualifier in GLSL). OptFragmentStoresAndAtomics // OptShaderTessellationAndGeometryPointSize specifies whether the PointSize built-in decoration is available in the tessellation control, tessellation evaluation, and geometry shader stages. If this feature is not enabled, members decorated with the PointSize built-in decoration must not be read from or written to and all points written from a tessellation or geometry shader will have a size of 1.0. This also specifies whether shader modules can declare the TessellationPointSize capability for tessellation control and evaluation shaders, or if the shader modules can declare the GeometryPointSize capability for geometry shaders. An implementation supporting this feature must also support one or both of the tessellationShader or geometryShader features. OptShaderTessellationAndGeometryPointSize // OptShaderImageGatherExtended specifies whether the extended set of image gather instructions are available in shader code. If this feature is not enabled, the OpImage*Gather instructions do not support the Offset and ConstOffsets operands. This also specifies whether shader modules can declare the ImageGatherExtended capability. OptShaderImageGatherExtended // OptShaderStorageImageExtendedFormats specifies whether all the “storage image extended formats” below are supported; if this feature is supported, then the VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT must be supported in optimalTilingFeatures various formats -- see the Vulkan Spec at https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkPhysicalDeviceFeatures.html OptShaderStorageImageExtendedFormats // OptShaderStorageImageMultisample specifies whether multisampled storage images are supported. If this feature is not enabled, images that are created with a usage that includes VK_IMAGE_USAGE_STORAGE_BIT must be created with samples equal to VK_SAMPLE_COUNT_1_BIT. This also specifies whether shader modules can declare the StorageImageMultisample and ImageMSArray capabilities. OptShaderStorageImageMultisample // OptShaderStorageImageReadWithoutFormat specifies whether storage images and storage texel buffers require a format qualifier to be specified when reading. shaderStorageImageReadWithoutFormat applies only to formats listed in the storage without format list. OptShaderStorageImageReadWithoutFormat // OptShaderStorageImageWriteWithoutFormat specifies whether storage images and storage texel buffers require a format qualifier to be specified when writing. shaderStorageImageWriteWithoutFormat applies only to formats listed in the storage without format list. OptShaderStorageImageWriteWithoutFormat // OptShaderUniformBufferArrayDynamicIndexing specifies whether arrays of uniform buffers can be indexed by dynamically uniform integer expressions in shader code. If this feature is not enabled, resources with a descriptor type of VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER or VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC must be indexed only by constant integral expressions when aggregated into arrays in shader code. This also specifies whether shader modules can declare the UniformBufferArrayDynamicIndexing capability. OptShaderUniformBufferArrayDynamicIndexing // OptShaderSampledImageArrayDynamicIndexing specifies whether arrays of samplers or sampled images can be indexed by dynamically uniform integer expressions in shader code. If this feature is not enabled, resources with a descriptor type of VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, or VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE must be indexed only by constant integral expressions when aggregated into arrays in shader code. This also specifies whether shader modules can declare the SampledImageArrayDynamicIndexing capability. OptShaderSampledImageArrayDynamicIndexing // OptShaderStorageBufferArrayDynamicIndexing specifies whether arrays of storage buffers can be indexed by dynamically uniform integer expressions in shader code. If this feature is not enabled, resources with a descriptor type of VK_DESCRIPTOR_TYPE_STORAGE_BUFFER or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC must be indexed only by constant integral expressions when aggregated into arrays in shader code. This also specifies whether shader modules can declare the StorageBufferArrayDynamicIndexing capability. OptShaderStorageBufferArrayDynamicIndexing // OptShaderStorageImageArrayDynamicIndexing specifies whether arrays of storage images can be indexed by dynamically uniform integer expressions in shader code. If this feature is not enabled, resources with a descriptor type of VK_DESCRIPTOR_TYPE_STORAGE_IMAGE must be indexed only by constant integral expressions when aggregated into arrays in shader code. This also specifies whether shader modules can declare the StorageImageArrayDynamicIndexing capability. OptShaderStorageImageArrayDynamicIndexing // OptShaderClipDistance specifies whether clip distances are supported in shader code. If this feature is not enabled, any members decorated with the ClipDistance built-in decoration must not be read from or written to in shader modules. This also specifies whether shader modules can declare the ClipDistance capability. OptShaderClipDistance // OptShaderCullDistance specifies whether cull distances are supported in shader code. If this feature is not enabled, any members decorated with the CullDistance built-in decoration must not be read from or written to in shader modules. This also specifies whether shader modules can declare the CullDistance capability. OptShaderCullDistance // OptShaderFloat64 specifies whether 64-bit floats (doubles) are supported in shader code. If this feature is not enabled, 64-bit floating-point types must not be used in shader code. This also specifies whether shader modules can declare the Float64 capability. Declaring and using 64-bit floats is enabled for all storage classes that SPIR-V allows with the Float64 capability. OptShaderFloat64 // OptShaderInt64 specifies whether 64-bit integers (signed and unsigned) are supported in shader code. If this feature is not enabled, 64-bit integer types must not be used in shader code. This also specifies whether shader modules can declare the Int64 capability. Declaring and using 64-bit integers is enabled for all storage classes that SPIR-V allows with the Int64 capability. OptShaderInt64 // OptShaderInt16 specifies whether 16-bit integers (signed and unsigned) are supported in shader code. If this feature is not enabled, 16-bit integer types must not be used in shader code. This also specifies whether shader modules can declare the Int16 capability. However, this only enables a subset of the storage classes that SPIR-V allows for the Int16 SPIR-V capability: Declaring and using 16-bit integers in the Private, Workgroup (for non-Block variables), and Function storage classes is enabled, while declaring them in the interface storage classes (e.g., UniformConstant, Uniform, StorageBuffer, Input, Output, and PushConstant) is not enabled. OptShaderInt16 // OptShaderResourceResidency specifies whether image operations that return resource residency information are supported in shader code. If this feature is not enabled, the OpImageSparse* instructions must not be used in shader code. This also specifies whether shader modules can declare the SparseResidency capability. The feature requires at least one of the sparseResidency* features to be supported. OptShaderResourceResidency // OptShaderResourceMinLod specifies whether image operations specifying the minimum resource LOD are supported in shader code. If this feature is not enabled, the MinLod image operand must not be used in shader code. This also specifies whether shader modules can declare the MinLod capability. OptShaderResourceMinLod // OptSparseBinding specifies whether resource memory can be managed at opaque sparse block level instead of at the object level. If this feature is not enabled, resource memory must be bound only on a per-object basis using the vkBindBufferMemory and vkBindImageMemory commands. In this case, buffers and images must not be created with VK_BUFFER_CREATE_SPARSE_BINDING_BIT and VK_IMAGE_CREATE_SPARSE_BINDING_BIT set in the flags member of the VkBufferCreateInfo and VkImageCreateInfo structures, respectively. Otherwise resource memory can be managed as described in Sparse Resource Features. OptSparseBinding // OptSparseResidencyBuffer specifies whether the device can access partially resident buffers. If this feature is not enabled, buffers must not be created with VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set in the flags member of the VkBufferCreateInfo structure. OptSparseResidencyBuffer // OptSparseResidencyImage2D specifies whether the device can access partially resident 2D images with 1 sample per pixel. If this feature is not enabled, images with an imageType of VK_IMAGE_TYPE_2D and samples set to VK_SAMPLE_COUNT_1_BIT must not be created with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set in the flags member of the VkImageCreateInfo structure. OptSparseResidencyImage2D // OptSparseResidencyImage3D specifies whether the device can access partially resident 3D images. If this feature is not enabled, images with an imageType of VK_IMAGE_TYPE_3D must not be created with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set in the flags member of the VkImageCreateInfo structure. OptSparseResidencyImage3D // OptSparseResidency2Samples specifies whether the physical device can access partially resident 2D images with 2 samples per pixel. If this feature is not enabled, images with an imageType of VK_IMAGE_TYPE_2D and samples set to VK_SAMPLE_COUNT_2_BIT must not be created with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set in the flags member of the VkImageCreateInfo structure. OptSparseResidency2Samples // OptSparseResidency4Samples specifies whether the physical device can access partially resident 2D images with 4 samples per pixel. If this feature is not enabled, images with an imageType of VK_IMAGE_TYPE_2D and samples set to VK_SAMPLE_COUNT_4_BIT must not be created with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set in the flags member of the VkImageCreateInfo structure. OptSparseResidency4Samples // OptSparseResidency8Samples specifies whether the physical device can access partially resident 2D images with 8 samples per pixel. If this feature is not enabled, images with an imageType of VK_IMAGE_TYPE_2D and samples set to VK_SAMPLE_COUNT_8_BIT must not be created with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set in the flags member of the VkImageCreateInfo structure. OptSparseResidency8Samples // OptSparseResidency16Samples specifies whether the physical device can access partially resident 2D images with 16 samples per pixel. If this feature is not enabled, images with an imageType of VK_IMAGE_TYPE_2D and samples set to VK_SAMPLE_COUNT_16_BIT must not be created with VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set in the flags member of the VkImageCreateInfo structure. OptSparseResidency16Samples // OptSparseResidencyAliased specifies whether the physical device can correctly access data aliased into multiple locations. If this feature is not enabled, the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT and VK_IMAGE_CREATE_SPARSE_ALIASED_BIT enum values must not be used in flags members of the VkBufferCreateInfo and VkImageCreateInfo structures, respectively. OptSparseResidencyAliased // OptVariableMultisampleRate specifies whether all pipelines that will be bound to a command buffer during a subpass which uses no attachments must have the same value for VkPipelineMultisampleStateCreateInfo::rasterizationSamples. If set to VK_TRUE, the implementation supports variable multisample rates in a subpass which uses no attachments. If set to VK_FALSE, then all pipelines bound in such a subpass must have the same multisample rate. This has no effect in situations where a subpass uses any attachments. OptVariableMultisampleRate // OptInheritedQueries specifies whether a secondary command buffer may be executed while a query is active. OptInheritedQueries )
func (*CPUOptions) FromString ¶ added in v1.0.27
func (i *CPUOptions) FromString(s string) error
func (CPUOptions) String ¶ added in v1.0.27
func (i CPUOptions) String() string
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 EndSubmitWaitFree logic.
func (*CmdPool) EndSubmitWait ¶ added in v1.0.10
EndSubmitWait does End, Submit, WaitIdle on Buffer
func (*CmdPool) EndSubmitWaitFree ¶ added in v1.0.10
EndSubmitWaitFree does End, Submit, WaitIdle, Free on Buffer
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 if Buff == nil, 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 Submit, WaitIdle on Buffer
type Device ¶
type Device struct { // logical device Device vk.Device `desc:"logical device"` // queue index for device QueueIndex uint32 `desc:"queue index for device"` // queue 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 { // target framebuffer format -- if multisampling is active then Image has samples = 1, Render.Multi has full samples Format ImageFormat `desc:"target framebuffer format -- if multisampling is active then Image has samples = 1, Render.Multi has full samples"` // the image behind the framebuffer, includes the format -- this Image Image `desc:"the image behind the framebuffer, includes the format -- this "` // pointer to the associated renderpass and depth buffer Render *Render `desc:"pointer to the associated renderpass and depth buffer"` // vulkan framebuffer Framebuffer vk.Framebuffer `desc:"vulkan framebuffer"` // has this framebuffer been cleared yet? if not, must be prior to use as a non-clearing Load case 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. call this after: sys.MemCmdEndSubmitWaitFree()
type GPU ¶
type GPU struct { // handle for the vulkan driver instance Instance vk.Instance `desc:"handle for the vulkan driver instance"` // handle for the vulkan physical GPU hardware GPU vk.PhysicalDevice `desc:"handle for the vulkan physical GPU hardware"` // options passed in during config UserOpts *GPUOpts `desc:"options passed in during config"` // set of enabled options set post-Config EnabledOpts GPUOpts `desc:"set of enabled options set post-Config"` // name of the physical GPU device DeviceName string `desc:"name of the physical GPU device"` // name of application -- set during Config and used in init of GPU AppName string `desc:"name of application -- set during Config and used in init of GPU"` // version of vulkan API to target APIVersion vk.Version `desc:"version of vulkan API to target"` // version of application -- optional AppVersion vk.Version `desc:"version of application -- optional"` // use Add method to add required instance extentions prior to calling Config InstanceExts []string `desc:"use Add method to add required instance extentions prior to calling Config"` // use Add method to add required device extentions prior to calling Config DeviceExts []string `desc:"use Add method to add required device extentions prior to calling Config"` // set Add method to add required validation layers prior to calling Config ValidationLayers []string `desc:"set Add method to add required validation layers prior to calling Config"` // this is used for computing, not graphics Compute bool `desc:"this is used for computing, not graphics"` // our custom debug callback DebugCallback vk.DebugReportCallback `desc:"our custom debug callback"` // properties of physical hardware -- populated after Config GPUProps vk.PhysicalDeviceProperties `desc:"properties of physical hardware -- populated after Config"` // features of physical hardware -- populated after Config GPUFeats vk.PhysicalDeviceFeatures `desc:"features of physical hardware -- populated after Config"` // properties of device memory -- populated after Config MemoryProps vk.PhysicalDeviceMemoryProperties `desc:"properties of device memory -- populated after Config"` // maximum number of compute threads per compute shader invokation, for a 1D number of threads per Warp, which is generally greater than MaxComputeWorkGroup[0], which allows for the [1] and [2] maxima as well. This is not defined anywhere in the formal spec, unfortunately, but has been determined empirically for Mac and NVIDIA which are two of the most relevant use-cases. If not a known case, the MaxComputeWorkGroup[0] value is used, which can significantly slow down compute processing if more could actually be used. Please file an issue or PR for other GPUs with known larger values. MaxComputeWorkGroupCount1D int `` /* 597-byte string literal not displayed */ // [view: -] platform-specific PNext for CreateDevice call PlatformDeviceNext unsafe.Pointer `view:"-" desc:"platform-specific PNext for CreateDevice call"` }
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) CheckGPUOpts ¶ added in v1.0.27
CheckGPUOpts checks if the required options are present. if report is true, a message is printed about missing features, and the state of the actual
func (*GPU) Config ¶
Config configures the GPU given the extensions set in InstanceExts, DeviceExts, and ValidationLayers, and the given GPUOpts options. Only the first such opts will be used -- the variable args is used to enable no options to be passed by default.
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) GetDeviceName ¶ added in v1.0.29
func (gp *GPU) GetDeviceName(props *vk.PhysicalDeviceProperties, idx int) string
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.
func (*GPU) SelectGPU ¶ added in v1.0.6
func (gp *GPU) SelectGPU(gpus []vk.PhysicalDevice, gpuCount int) int
func (*GPU) SetGPUOpts ¶ added in v1.0.27
func (gp *GPU) SetGPUOpts(feats *vk.PhysicalDeviceFeatures, opts GPUOpts)
SetGPUOpts sets the Enabled optional features in given features struct
type GPUOpts ¶ added in v1.0.27
type GPUOpts map[CPUOptions]OptionStates
GPUOpts is the collection of CPUOption states
var DefaultOpts *GPUOpts
DefaultOpts are default GPU config options that can be set by any app prior to initializing the GPU object -- this may be easier than passing options in from the app during the Config call. Any such options take precedence over these options (usually best to avoid direct conflits -- monitor Debug output to see).
func NewRequiredOpts ¶ added in v1.0.27
func NewRequiredOpts(opts ...CPUOptions) GPUOpts
NewRequiredOpts returns a new GPUOpts with all of the given options as Required.
func (*GPUOpts) Add ¶ added in v1.0.27
func (co *GPUOpts) Add(opt CPUOptions, state OptionStates)
Add adds the given option state
func (*GPUOpts) CopyFrom ¶ added in v1.0.28
CopyFrom copies options from another opts collection, overwriting any existing in this map.
func (*GPUOpts) State ¶ added in v1.0.27
func (co *GPUOpts) State(opt CPUOptions) OptionStates
State returns the state of the given option. Any option not explicitly set is assumed to be Disabled.
type HostImage ¶
type HostImage struct { // size in bytes allocated for host representation of image Size int `desc:"size in bytes allocated for host representation of image"` // [view: -] buffer for host CPU-visible memory, for staging -- can be owned by us or managed by Memory (for Val) 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 into host buffer, when Buff is Memory managed Offset int `desc:"offset into host buffer, when Buff is Memory managed"` // [view: -] host CPU-visible memory, for staging, when we manage our own memory Mem vk.DeviceMemory `view:"-" desc:"host CPU-visible memory, for staging, when we manage our own memory"` // [view: -] memory mapped pointer into host memory -- remains mapped 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 of the image -- e.g., same as Val name if used that way -- helpful for debugging -- set to filename if loaded from a file and otherwise empty Name string `` /* 153-byte string literal not displayed */ // bit flags for image state, for indicating nature of ownership and state Flags int32 `desc:"bit flags for image state, for indicating nature of ownership and state"` // format & size of image Format ImageFormat `desc:"format & size of image"` // [view: -] vulkan image handle, in device memory Image vk.Image `view:"-" desc:"vulkan image handle, in device memory"` // [view: -] vulkan image view View vk.ImageView `view:"-" desc:"vulkan image view"` // [view: -] memory for image when we allocate it Mem vk.DeviceMemory `view:"-" desc:"memory for image when we allocate it"` // [view: -] keep track of device for destroying view Dev vk.Device `view:"-" desc:"keep track of device for destroying view"` // host memory buffer representation of the image Host HostImage `desc:"host memory buffer representation of the image"` // pointer to our GPU 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 of image Size image.Point `desc:"Size of image"` // Image format -- FormatR8g8b8a8Srgb is a standard default Format vk.Format `desc:"Image format -- FormatR8g8b8a8Srgb is a standard default"` // number of samples -- set higher for Framebuffer rendering but otherwise default of SampleCount1Bit Samples vk.SampleCountFlagBits `desc:"number of samples -- set higher for Framebuffer rendering but otherwise default of SampleCount1Bit"` // number of layers for texture arrays 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) IsRGBAUnorm ¶ added in v1.0.22
func (im *ImageFormat) IsRGBAUnorm() bool
IsRGBAUnorm returns true if image format is the vk.FormatR8g8b8a8Unorm format which is compatible with go image.RGBA format with colorspace conversion.
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) NSamples ¶ added in v1.0.22
func (im *ImageFormat) NSamples() int
NSamples returns the integer number of samples based on Samples flag setting
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 of memory in this buffer Type BuffTypes `desc:"type of memory in this buffer"` // allocated buffer size Size int `desc:"allocated buffer size"` // [view: -] logical descriptor for host CPU-visible memory, for staging Host vk.Buffer `view:"-" desc:"logical descriptor for host CPU-visible memory, for staging"` // [view: -] host CPU-visible memory, for staging HostMem vk.DeviceMemory `view:"-" desc:"host CPU-visible memory, for staging"` // [view: -] logical descriptor for device GPU-local memory, for computation Dev vk.Buffer `view:"-" desc:"logical descriptor for device GPU-local memory, for computation"` // [view: -] device GPU-local memory, for computation DevMem vk.DeviceMemory `view:"-" desc:"device GPU-local memory, for computation"` // [view: -] memory mapped pointer into host memory -- remains mapped HostPtr unsafe.Pointer `view:"-" desc:"memory mapped pointer into host memory -- remains mapped"` // alignment of offsets into this buffer AlignBytes int `desc:"alignment of offsets into this buffer"` // true if memory has been allocated, copied, transfered 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 MemReg ¶
type MemReg struct { Offset int Size int BuffType BuffTypes BuffIdx int // for storage buffers, storage buffer index }
MemReg is a region of memory for transferring to / from GPU
type Memory ¶
type Memory struct { GPU *GPU // logical device that this memory is managed for -- set from System Device Device `desc:"logical device that this memory is managed for -- set from System"` // command pool for memory transfers CmdPool CmdPool `desc:"command pool for memory transfers"` // Vars variables used in shaders, which manage associated Vals containing specific value instances of each var Vars Vars `desc:"Vars variables used in shaders, which manage associated Vals containing specific value instances of each var"` // memory buffers, organized by different Roles of vars. Storage is managed separately in StorageBuffs Buffs [BuffTypesN]*MemBuff `desc:"memory buffers, organized by different Roles of vars. Storage is managed separately in StorageBuffs"` // memory buffers for storage -- vals are allocated to buffers during AllocHost, grouping based on what fits within GPU limits StorageBuffs []*MemBuff `` /* 130-byte string literal not displayed */ // memory allocation records for storage buffer allocation, per variable StorageMems []*VarMem `desc:"memory allocation records for storage buffer allocation, per variable"` }
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) AllocHostStorageBuff ¶ added in v1.0.32
func (mm *Memory) AllocHostStorageBuff()
AllocHostStorageBuff allocates host memory for all storage buffers
func (*Memory) CmdTransferRegsFmGPU ¶ added in v1.0.19
func (mm *Memory) CmdTransferRegsFmGPU(cmd vk.CommandBuffer, buff *MemBuff, regs []MemReg)
CmdTransferRegsFmGPU transfers memory from GPU to CPU for given regions by recording command to given buffer.
func (*Memory) CmdTransferRegsToGPU ¶ added in v1.0.19
func (mm *Memory) CmdTransferRegsToGPU(cmd vk.CommandBuffer, buff *MemBuff, regs []MemReg)
CmdTransferRegsToGPU transfers memory from CPU to GPU for given regions by recording command to given buffer.
func (*Memory) CmdTransferStorageBuffRegsFmGPU ¶ added in v1.0.32
func (mm *Memory) CmdTransferStorageBuffRegsFmGPU(cmd vk.CommandBuffer, buff *MemBuff, buffIdx int, regs []MemReg)
CmdTransferStorageBuffRegsFmGPU transfers memory from GPU to CPU for given regions by recording command to given storage buffer of given index.
func (*Memory) CmdTransferStorageBuffRegsToGPU ¶ added in v1.0.32
func (mm *Memory) CmdTransferStorageBuffRegsToGPU(cmd vk.CommandBuffer, buff *MemBuff, buffIdx int, regs []MemReg)
CmdTransferStorageBuffRegsToGPU transfers memory from CPU to GPU for given regions by recording command to given storage buffer of given index.
func (*Memory) CmdTransferStorageRegsFmGPU ¶ added in v1.0.32
func (mm *Memory) CmdTransferStorageRegsFmGPU(cmd vk.CommandBuffer, regs []MemReg)
CmdTransferStorageRegsFmGPU transfers memory from GPU to CPU for given storage regions by recording command to given command buffer.
func (*Memory) CmdTransferStorageRegsToGPU ¶ added in v1.0.32
func (mm *Memory) CmdTransferStorageRegsToGPU(cmd vk.CommandBuffer, regs []MemReg)
CmdTransferStorageRegsToGPU transfers memory from CPU to GPU for given storage regions by recording command to given command 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(). Note: dynamic binding must be called separately after this.
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) SyncRegionValIdx ¶ added in v1.0.18
SyncRegionValIdx returns memory region for syncing 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. Multiple regions can be combined into one transfer call for greater efficiency.
func (*Memory) SyncRegionValName ¶ added in v1.0.18
SyncRegionValName returns memory region for syncing 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. Multiple regions can be combined into one transfer call for greater efficiency.
func (*Memory) SyncStorageRegionsFmGPU ¶ added in v1.0.18
SyncStorageRegionsFmGPU syncs given regions from the Storage buffer memory from GPU to CPU, in one call. Use SyncRegValIdxFmCPU to get the regions.
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) 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, using a one-time memory command buffer. All buffs must be of the same type.
func (*Memory) TransferRegsToGPU ¶
TransferRegsToGPU transfers memory from CPU to GPU for given regions, using a one-time memory command buffer. All buffs must be of the same type.
func (*Memory) TransferStorageRegsFmGPU ¶ added in v1.0.32
TransferStorageRegsFmGPU transfers memory from GPU to CPU for given regions, using a one-time memory command buffer, for Storage
func (*Memory) TransferStorageRegsToGPU ¶ added in v1.0.32
TransferStorageRegsToGPU transfers memory from CPU to GPU for given regions, using a one-time memory command buffer, for Storage
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 OptionStates ¶ added in v1.0.27
type OptionStates int32
OptionStates are options for the physical device features
const ( // Disabled -- option is not enabled Disabled OptionStates = iota // Optional -- option is enabled if possible // and code checks for actual state providing // workaround if not supported Optional // Required -- option is required and GPU.Config // fails if not supported by the hardware Required // Enabled is the state of all options specified // during Config, and supported bythe hardware Enabled OptionStatesN )
func (*OptionStates) FromString ¶ added in v1.0.27
func (i *OptionStates) FromString(s string) error
func (OptionStates) String ¶ added in v1.0.27
func (i OptionStates) String() string
type Pipeline ¶
type Pipeline struct { // unique name of this pipeline Name string `desc:"unique name of this pipeline"` // system that we belong to and manages all shared resources (Memory, Vars, Vals, etc), etc Sys *System `desc:"system that we belong to and manages all shared resources (Memory, Vars, Vals, etc), etc"` // shaders in order added -- should be execution order Shaders []*Shader `desc:"shaders in order added -- should be execution order"` // shaders loaded for this pipeline ShaderMap map[string]*Shader `desc:"shaders loaded for this pipeline"` // vulkan pipeline configuration options VkConfig vk.GraphicsPipelineCreateInfo `desc:"vulkan pipeline configuration options"` // the created vulkan pipeline VkPipeline vk.Pipeline `desc:"the created vulkan pipeline"` // cache 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) AddShaderEmbed ¶ added in v1.0.12
func (pl *Pipeline) AddShaderEmbed(name string, typ ShaderTypes, efs embed.FS, fname string) *Shader
AddShaderEmbed adds Shader with given name and type to the pipeline, Loading SPV code from given file name in embed.FS filesystem.
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) ComputeDispatch ¶ added in v1.0.32
func (pl *Pipeline) ComputeDispatch(cmd vk.CommandBuffer, nx, ny, nz int)
ComputeDispatch adds commands to given cmd buffer to run the compute shader for given number of *warps* (groups of threads) along 3 dimensions, which then generate indexes passed into the shader. In HLSL, the [numthreads(x, y, z)] directive specifies the number of threads allocated per warp -- the actual number of elements processed is threads * warps per each dimension. See Warps function. The hardware typically has 32 (NVIDIA, M1, M2) or 64 (AMD) hardware threads per warp, and so 64 is typically used as a default sum of threads per warp across all of the dimensions. Can use subsets of dimensions by using 1 for the other dimensions, and see ComputeDispatch1D for a convenience method that automatically computes the number of warps for a 1D compute shader (everthing in x). Must have a CmdBegin already executed, either via ComputeBindVars or ComputeResetBegin call. Must call CommandSubmit[Wait] to execute the command.
func (*Pipeline) ComputeDispatch1D ¶ added in v1.0.32
func (pl *Pipeline) ComputeDispatch1D(cmd vk.CommandBuffer, n, threads int)
ComputeDispatch1D adds commands to run the compute shader for given number of computational elements along the first (X) dimension, for given number *elements* and threads per warp (typically 64). See ComputeDispatch for full info. This is just a convenience method for common 1D case that calls the Warps method for you.
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 Note: must enable OptFillModeNonSolid option for Line or Point fill mode.
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 { // system that we belong to and manages all shared resources (Memory, Vars, Vals, etc), etc Sys *System `desc:"system that we belong to and manages all shared resources (Memory, Vars, Vals, etc), etc"` // the device we're associated with -- this must be the same device that owns the Framebuffer -- e.g., the Surface Dev vk.Device `desc:"the device we're associated with -- this must be the same device that owns the Framebuffer -- e.g., the Surface"` // image format information for the framebuffer we render to Format ImageFormat `desc:"image format information for the framebuffer we render to"` // the associated depth buffer, if set Depth Image `desc:"the associated depth buffer, if set"` // is true if configured with depth buffer HasDepth bool `desc:"is true if configured with depth buffer"` // for multisampling, this is the multisampled image that is the actual render target Multi Image `desc:"for multisampling, this is the multisampled image that is the actual render target"` // is true if multsampled image configured HasMulti bool `desc:"is true if multsampled image configured"` // host-accessible image that is used to transfer back from a render color attachment to host memory -- requires a different format than color attachment, and is ImageOnHostOnly flagged. Grab Image `` /* 190-byte string literal not displayed */ // host-accessible buffer for grabbing the depth map -- must go to a buffer and not an image GrabDepth MemBuff `desc:"host-accessible buffer for grabbing the depth map -- must go to a buffer and not an image"` // set this to true if it is not using a Surface render target (i.e., it is a RenderFrame) NotSurface bool `desc:"set this to true if it is not using a Surface render target (i.e., it is a RenderFrame)"` // values for clearing image when starting render pass ClearVals []vk.ClearValue `desc:"values for clearing image when starting render pass"` // the vulkan renderpass config that clears target first VkClearPass vk.RenderPass `desc:"the vulkan renderpass config that clears target first"` // the vulkan renderpass config that does not clear target first (loads previous) 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) ConfigGrabDepth ¶ added in v1.0.22
ConfigGrabDepth configures the GrabDepth for copying depth image back to host memory. Uses format of current Depth image.
func (*Render) ConfigImpl ¶
func (rp *Render) ConfigImpl(dev vk.Device, imgFmt *ImageFormat, depthFmt Types, clear bool) vk.RenderPass
func (*Render) DepthImageArray ¶ added in v1.0.22
DepthImageArray returns the float values from the last GrabDepthImage call automatically handles down-sampling from multisampling.
func (*Render) GrabDepthImage ¶ added in v1.0.22
GrabDepthImage grabs the current render depth image, using given command buffer which must have the cmdBegin called already. Uses the GrabDepth Storage Buffer. call this after: sys.MemCmdEndSubmitWaitFree()
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 { // pointer to gpu device, for convenience GPU *GPU `desc:"pointer to gpu device, for convenience"` // device for this surface -- each window surface has its own device, configured for that surface Device Device `desc:"device for this surface -- each window surface has its own device, configured for that surface"` // the Render for this RenderFrame, typically from a System Render *Render `desc:"the Render for this RenderFrame, typically from a System"` // has the current image format and dimensions Format ImageFormat `desc:"has the current image format and dimensions"` // number of frames to maintain in the swapchain -- e.g., 2 = double-buffering, 3 = triple-buffering -- initially set to a requested amount, and after Init reflects actual number NFrames int `` /* 182-byte string literal not displayed */ // Framebuffers representing the Image owned by the RenderFrame -- we iterate through these in rendering subsequent frames Frames []*Framebuffer `` /* 126-byte string literal not displayed */ // [view: -] semaphore used internally for waiting on acquisition of next frame ImageAcquired vk.Semaphore `view:"-" desc:"semaphore used internally for waiting on acquisition of next frame"` // [view: -] semaphore that surface user can wait on, will be activated when image has been acquired in AcquireNextFrame method RenderDone vk.Semaphore `` /* 130-byte string literal not displayed */ // [view: -] fence for rendering command running RenderFence vk.Fence `view:"-" desc:"fence for rendering command running"` // do we own the device? 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) GrabDepthImage ¶ added in v1.0.22
func (rf *RenderFrame) GrabDepthImage(cmd vk.CommandBuffer)
GrabDepthImage grabs rendered depth image from the Render, must have waited for render already.
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 // for U (horizontal) axis -- what to do when going off the edge UMode SamplerModes `desc:"for U (horizontal) axis -- what to do when going off the edge"` // for V (vertical) axis -- what to do when going off the edge VMode SamplerModes `desc:"for V (vertical) axis -- what to do when going off the edge"` // for W (horizontal) 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 color for Clamp modes Border BorderColors `desc:"border color for Clamp modes"` // the vulkan sampler 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 { // pointer to gpu device, for convenience GPU *GPU `desc:"pointer to gpu device, for convenience"` // device for this surface -- each window surface has its own device, configured for that surface Device Device `desc:"device for this surface -- each window surface has its own device, configured for that surface"` // the Render for this Surface, typically from a System Render *Render `desc:"the Render for this Surface, typically from a System"` // has the current swapchain image format and dimensions Format ImageFormat `desc:"has the current swapchain image format and dimensions"` // ordered list of surface formats to select DesiredFormats []vk.Format `desc:"ordered list of surface formats to select"` // number of frames to maintain in the swapchain -- e.g., 2 = double-buffering, 3 = triple-buffering -- initially set to a requested amount, and after Init reflects actual number NFrames int `` /* 182-byte string literal not displayed */ // Framebuffers representing the visible Image owned by the Surface -- we iterate through these in rendering subsequent frames Frames []*Framebuffer `` /* 130-byte string literal not displayed */ // [view: -] vulkan handle for surface Surface vk.Surface `view:"-" desc:"vulkan handle for surface"` // [view: -] vulkan handle for swapchain Swapchain vk.Swapchain `view:"-" desc:"vulkan handle for swapchain"` // [view: -] semaphore used internally for waiting on acquisition of next frame ImageAcquired vk.Semaphore `view:"-" desc:"semaphore used internally for waiting on acquisition of next frame"` // [view: -] semaphore that surface user can wait on, will be activated when image has been acquired in AcquireNextFrame method RenderDone vk.Semaphore `` /* 130-byte string literal not displayed */ // [view: -] fence for rendering command running 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 before the command is run.
type System ¶
type System struct { // optional name of this System Name string `desc:"optional name of this System"` // gpu device GPU *GPU `desc:"gpu device"` // logical device for this System, which is a non-owned copy of either Surface or RenderFrame device Device Device `desc:"logical device for this System, which is a non-owned copy of either Surface or RenderFrame device"` // cmd pool specific to this system CmdPool CmdPool `desc:"cmd pool specific to this system"` // if true, this is a compute system -- otherwise is graphics Compute bool `desc:"if true, this is a compute system -- otherwise is graphics"` // if true, variables are statically bound to specific offsets in memory buffers, vs. dynamically bound offsets. Typically a compute shader operating on fixed data variables can use static binding, while graphics (e.g., vphong) requires dynamic binding to efficiently use the same shader code for multiple different values of the same variable type StaticVars bool `` /* 353-byte string literal not displayed */ // all pipelines Pipelines []*Pipeline `desc:"all pipelines"` // map of all pipelines -- names must be unique PipelineMap map[string]*Pipeline `desc:"map of all pipelines -- names must be unique"` // map of events for synchronizing processing within a single command stream -- this is the best method for compute shaders to coordinate within a given sequence of shader runs in a single command stream Events map[string]vk.Event `` /* 207-byte string literal not displayed */ // map of semaphores for GPU-side sync between different submitted commands -- names must be unique -- note: better to use Events within one command if possible. Semaphores map[string]vk.Semaphore `` /* 165-byte string literal not displayed */ // map of fences for CPU-GPU sync -- names must be unique. WaitIdle implictly uses a fence so it is not essential to use this for simple wait case Fences map[string]vk.Fence `` /* 151-byte string literal not displayed */ // map of command buffers, for persistent recorded commands -- names must be unique CmdBuffs map[string]vk.CommandBuffer `desc:"map of command buffers, for persistent recorded commands -- names must be unique"` // manages all the memory for all the Vals Mem Memory `desc:"manages all the memory for all the Vals"` // renderpass with depth buffer for this system 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) CmdBuffByNameTry ¶ added in v1.0.22
func (sy *System) CmdBuffByNameTry(name string) (vk.CommandBuffer, error)
CmdBuffByNameTry returns fence by name with error for not found
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) ComputeCmdBuff ¶ added in v1.0.32
func (sy *System) ComputeCmdBuff() vk.CommandBuffer
ComputeCmdBuff returns the default compute command buffer: CmdPool.Buff which can be used for executing arbitrary compute commands.
func (*System) ComputeCmdEnd ¶ added in v1.0.20
func (sy *System) ComputeCmdEnd(cmd vk.CommandBuffer)
ComputeCmdEnd adds an end to given command buffer
func (*System) ComputeCopyFmGPU ¶ added in v1.0.32
func (sy *System) ComputeCopyFmGPU(cmd vk.CommandBuffer, regs ...MemReg)
ComputeCopyFmGPU records command to copy given regions in the Storage buffer memory from GPU to CPU, in one call. Use SyncRegValIdxFmCPU to get the regions.
func (*System) ComputeCopyToGPU ¶ added in v1.0.32
func (sy *System) ComputeCopyToGPU(cmd vk.CommandBuffer, regs ...MemReg)
ComputeCopyToGPU records command to copy given regions in the Storage buffer memory from CPU to GPU, in one call. Use SyncRegValIdxFmCPU to get the regions.
func (*System) ComputeResetBegin ¶ added in v1.0.8
func (sy *System) ComputeResetBegin(cmd vk.CommandBuffer)
ComputeResetBegin resets and begins the recording of commands the given command buffer -- use prior to ComputeCommand if not needing to call ComputeBindVars
func (*System) ComputeResetBindVars ¶ added in v1.0.19
func (sy *System) ComputeResetBindVars(cmd vk.CommandBuffer, descIdx int)
ComputeResetBindVars adds command to the given 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) ComputeSetEvent ¶ added in v1.0.19
func (sy *System) ComputeSetEvent(cmd vk.CommandBuffer, event string) error
ComputeSetEvent sets an event to be signalled when everything up to this point in the named command buffer has completed. This is the best way to coordinate processing within a sequence of compute shader calls within a single command buffer. Returns an error if the named event was not found.
func (*System) ComputeSubmitSignal ¶ added in v1.0.16
func (sy *System) ComputeSubmitSignal(cmd vk.CommandBuffer, signal, fence string) error
ComputeSubmitSignal submits command in buffer to system device queue with given signal semaphore (by name) when done, and with given fence (use empty string for none). The optional fence is used typically at the end of a block of such commands, whenever the CPU needs to be sure the submitted GPU commands have completed. Must use "ComputeWait" if using std ComputeWait function.
func (*System) ComputeSubmitWait ¶ added in v1.0.8
func (sy *System) ComputeSubmitWait(cmd vk.CommandBuffer)
ComputeSubmitWait submits the current set of commands in the default system CmdPool, typically from ComputeDispatch. Then waits for the commands to finish before returning control to the CPU. Results will be available immediately thereafter for retrieving back from the GPU.
func (*System) ComputeSubmitWaitSignal ¶ added in v1.0.16
func (sy *System) ComputeSubmitWaitSignal(cmd vk.CommandBuffer, wait, signal, fence string) error
ComputeSubmitWaitSignal submits command in given buffer to system device queue with given wait semaphore and given signal semaphore (by name) when done, and with given fence (use empty string for none). This will cause the GPU to wait until the wait semphaphore is signaled by a previous command with that semaphore as its signal. The optional fence is used typically at the end of a block of such commands, whenever the CPU needs to be sure the submitted GPU commands have completed. Must use "ComputeWait" if using std ComputeWait function.
func (*System) ComputeWait ¶ added in v1.0.8
ComputeWait waits for the standard ComputeWait fence
func (*System) ComputeWaitEvents ¶ added in v1.0.19
func (sy *System) ComputeWaitEvents(cmd vk.CommandBuffer, event ...string) error
ComputeWaitEvents waits until previous ComputeSetEvent event(s) have signalled. This is the best way to coordinate processing within a sequence of compute shader calls within named command buffer. However, use ComputeWaitMem* calls (e.g., WriteRead) to ensure memory writes have completed, instead of creating an Event. Returns an error if the named event was not found.
func (*System) ComputeWaitFence ¶ added in v1.0.16
ComputeWaitFence waits for given fence (by name), and resets the fence
func (*System) ComputeWaitMemHostToShader ¶ added in v1.0.32
func (sy *System) ComputeWaitMemHostToShader(cmd vk.CommandBuffer)
ComputeWaitMemHostToShader records pipeline barrier ensuring global memory writes from the host to shader have completed. Use this if the first commands are to copy memory from host, instead of creating a separate Event.
func (*System) ComputeWaitMemShaderToHost ¶ added in v1.0.32
func (sy *System) ComputeWaitMemShaderToHost(cmd vk.CommandBuffer)
ComputeWaitMemShaderToHost records pipeline barrier ensuring global memory writes have completed from the compute shader, and are ready for the host to read. This is not necessary if a standard QueueWaitIdle is done at the end of a command (basically not really needed, but included for completeness).
func (*System) ComputeWaitMemWriteRead ¶ added in v1.0.32
func (sy *System) ComputeWaitMemWriteRead(cmd vk.CommandBuffer)
ComputeWaitMemWriteRead records pipeline barrier ensuring global memory writes from the shader have completed and are ready to read in the next step of a command queue. Use this instead of Events to synchronize steps of a computation.
func (*System) ComputeWaitMemoryBuff ¶ added in v1.0.32
func (sy *System) ComputeWaitMemoryBuff(cmd vk.CommandBuffer, buff *MemBuff)
ComputeWaitMemoryBuff records pipeline barrier ensuring given buffer's memory writes have completed for given buffer from the compute shader, and are ready for the host to read. Vulkan docs suggest that global memory buffer barrier is generally better to use (ComputeWaitMem*)
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 initialized but are allocated from the Vars on this call, so the total number of Vals per Var, and number of VarSets, all must be configured.
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) EventByNameTry ¶ added in v1.0.19
EventByNameTry returns event by name with error for not found
func (*System) FenceByNameTry ¶ added in v1.0.16
FenceByNameTry returns fence by name with error for not found
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) MemCmdEndSubmitWaitFree ¶ added in v1.0.10
func (sy *System) MemCmdEndSubmitWaitFree()
MemCmdEndSubmitWaitFree 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) 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) NewCmdBuff ¶ added in v1.0.22
func (sy *System) NewCmdBuff(name string) vk.CommandBuffer
NewCmdBuff returns a new fence using system device
func (*System) NewComputePipelineEmbed ¶ added in v1.0.12
NewComputePipelineEmbed returns a new pipeline added to this System, using given file name from given embed.FS filesystem as a ComputeShader.
func (*System) NewPipeline ¶
NewPipeline returns a new pipeline added to this System, initialized for use in this system.
func (*System) NewSemaphore ¶ added in v1.0.16
NewSemaphore returns a new semaphore using system device
func (*System) PipelineByNameTry ¶ added in v1.0.16
PipelineByNameTry returns pipeline by name with error for not found
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) SemaphoreByNameTry ¶ added in v1.0.16
SemaphoreByNameTry returns semaphore by name with error for not found
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 of this value, named by default as the variable name_idx Name string `desc:"name of this value, named by default as the variable name_idx"` // index of this value within the Var list of values Idx int `desc:"index of this value within the Var list of values"` // actual number of elements in an array -- 1 means scalar / singular value. If 0, this is a dynamically sized item and the size must be set. N int `` /* 146-byte string literal not displayed */ // offset in bytes from start of memory buffer Offset int `desc:"offset in bytes from start of memory buffer"` // val state flags Flags int32 `desc:"val state flags"` // if N > 1 (array) then this is the effective size of each element, which must be aligned to 16 byte modulo for Uniform types. non naturally-aligned types require slower element-by-element syncing operations, instead of memcopy. ElSize int `` /* 234-byte string literal not displayed */ // total memory size of this value in bytes, as allocated, including array alignment but not any additional buffer-required alignment padding AllocSize int `` /* 145-byte string literal not displayed */ // for Texture Var roles, this is the Texture Texture *Texture `desc:"for Texture Var roles, this is the Texture"` // [view: -] pointer to the start of the staging memory for this value 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 { // values in indexed order Vals []*Val `desc:"values in indexed order"` // map of vals by name -- only for specifically named vals vs. generically allocated ones -- names must be unique NameMap map[string]*Val `desc:"map of vals by name -- only for specifically named vals vs. generically allocated ones -- names must be unique"` // for texture values, this allocates textures to texture arrays by size -- used if On flag is set -- must call AllocTexBySize to allocate after ConfigGoImage is called on all vals. Then call SetGoImage method on Vals to set the Go Image for each val -- this automatically redirects to the group allocated images. TexSzAlloc szalloc.SzAlloc `` /* 318-byte string literal not displayed */ // for texture values, if AllocTexBySize is called, these are the actual allocated image arrays that hold the grouped images (size = TexSzAlloc.GpAllocs. 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 { // variable name Name string `desc:"variable name"` // type of data in variable. Note that there are strict contraints on the alignment of fields within structs -- if you can keep all fields at 4 byte increments, that works, but otherwise larger fields trigger a 16 byte alignment constraint. Texture Images do not have such alignment constraints, and can be allocated in a big host buffer or in separate buffers depending on how frequently they are updated with different sizes. Type Types `` /* 433-byte string literal not displayed */ // number of elements if this is a fixed array -- use 1 if singular element, and 0 if a variable-sized array, where each Val can have its own specific size. This also works for arrays of Textures -- up to 128 max. ArrayN int `` /* 217-byte string literal not displayed */ // role of variable: Vertex is configured in the pipeline VkConfig structure, and everything else is configured in a DescriptorSet. For TextureRole items, the last such Var in a set will automatically be flagged as variable sized, so the shader can specify: #extension GL_EXT_nonuniform_qualifier : require and the list of textures can be specified as a [] array. Role VarRoles `` /* 368-byte string literal not displayed */ // bit flags for set of shaders that this variable is used in Shaders vk.ShaderStageFlagBits `desc:"bit flags for set of shaders that this variable is used in"` // DescriptorSet associated with the timing of binding for this variable -- all vars updated at the same time should be in the same set Set int `` /* 139-byte string literal not displayed */ // binding or location number for variable -- Vertexs are assigned as one group sequentially in order listed in Vars, and rest are assigned uniform binding numbers via descriptor pools BindLoc int `` /* 188-byte string literal not displayed */ // size in bytes of one element (not array size). Note that arrays in Uniform require 16 byte alignment for each element, so if using arrays, it is best to work within that constraint. In Storage, with HLSL compute shaders, 4 byte (e.g., float32 or int32) works fine as an array type. For Push role, SizeOf must be set exactly -- no vals are created. SizeOf int `` /* 357-byte string literal not displayed */ // texture manages its own memory allocation -- set this for texture objects that change size dynamically -- otherwise image host staging memory is allocated in a common buffer TextureOwns bool `` /* 193-byte string literal not displayed */ // index into the dynamic offset list, where dynamic offsets of vals need to be set -- for Uniform and Storage roles -- set during Set:DescLayout DynOffIdx int `` /* 162-byte string literal not displayed */ // the array of values allocated for this variable. The size of this array is determined by the Set membership of this Var, and the current index is updated at the set level. For Texture Roles, there is a separate descriptor for each value (image) -- otherwise dynamic offset binding is used. Vals Vals `` /* 298-byte string literal not displayed */ // for dynamically bound vars (Vertex, Uniform, Storage), this is the index of the currently bound value in Vals list -- index in this array is the descIdx out of Vars NDescs (see for docs) to allow for parallel update pathways -- only valid until set again -- only actually used for Vertex binding, as unforms etc have the WriteDescriptor mechanism. BindValIdx []int `` /* 367-byte string literal not displayed */ // index of the storage buffer in Memory that holds this Var -- for Storage buffer types. Due to support for dynamic binding, all Vals of a given Var must be stored in the same buffer, and the allocation mechanism ensures this. This constrains large vars approaching the MaxStorageBufferRange capacity to only have 1 val, which is typically reasonable given that compute shaders use large data and tend to use static binding anyway, and graphics uses tend to be smaller. StorageBuff int `` /* 489-byte string literal not displayed */ // offset -- only for push constants Offset int `inactive:"+" 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) MemSizeStorage ¶ added in v1.0.32
MemSizeStorage adds a Storage memory allocation record to Memory for all values for this Var
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 { // variables in order Vars []*Var `desc:"variables in order"` // map of vars by name -- names must be unique 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 VarMem ¶ added in v1.0.32
type VarMem struct { // variable -- all Vals of given Var are stored in the same Buffer Var *Var `desc:"variable -- all Vals of given Var are stored in the same Buffer"` // index into storage buffer array holding this value Buff int `desc:"index into storage buffer array holding this value"` // total size needed for this value, excluding alignment padding Size int `desc:"total size needed for this value, excluding alignment padding"` // allocated offset within storage buffer for start of Var memory Offset int `desc:"allocated offset within storage buffer for start of Var memory"` }
VarMem is memory allocation info per Var, for Storage types. Used in initial allocation algorithm.
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
func (VarRoles) VkDescriptorStatic ¶ added in v1.0.32
func (vr VarRoles) VkDescriptorStatic() vk.DescriptorType
VkDescriptorStatic returns the vk.DescriptorType for static variable binding type
type VarSet ¶
type VarSet struct { VarList // set number Set int `desc:"set number"` // number of value instances to allocate per variable in this set: each value must be allocated in advance for each unique instance of a variable required across a complete scene rendering -- e.g., if this is an object position matrix, then one per object is required. If a dynamic number are required, allocate the max possible. For Texture vars, each of the NDesc sets can have a maximum of MaxTexturesPerSet (16) -- if NValsPer > MaxTexturesPerSet, then vals are wrapped across sets, and accessing them requires using the appropriate DescIdx, as in System.CmdBindTextureVarIdx. NValsPer int `` /* 586-byte string literal not displayed */ // for texture vars, this is the number of descriptor sets required to represent all of the different Texture image Vals that have been allocated. Use Vars.BindAllTextureVals to bind all such vals, and System.CmdBindTextureVarIdx to automatically bind the correct set. NTextureDescs int `` /* 273-byte string literal not displayed */ // map of vars by different roles, within this set -- updated in Config(), after all vars added RoleMap map[VarRoles][]*Var `desc:"map of vars by different roles, within this set -- updated in Config(), after all vars added"` // the parent vars we belong to ParentVars *Vars `desc:"the parent vars we belong to"` // set layout info -- static description of each var type, role, binding, stages VkLayout vk.DescriptorSetLayout `desc:"set layout info -- static description of each var type, role, binding, stages"` // allocated descriptor set -- one of these per Vars.NDescs -- can have multiple sets that can be independently updated, e.g., for parallel rendering passes. If only rendering one at a time, only need one. 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) BindDynValsAllIdx ¶ added in v1.0.32
BindDynValsAllIdx dynamically binds all uniform, storage values in given set, for all variables, for given value index.
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.
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, 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) BindStatVarsAll ¶ added in v1.0.32
BindStatVarsAll dynamically binds all uniform, storage values in given set, for all variables, for all values.
Must call BindVarStart / End around this.
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 { // map of sets, by set number -- VertexSet is -2, PushSet is -1, rest are added incrementally SetMap map[int]*VarSet `desc:"map of sets, by set number -- VertexSet is -2, PushSet is -1, rest are added incrementally"` // map of vars by different roles across all sets -- updated in Config(), after all vars added. This is needed for VkDescPool allocation. RoleMap map[VarRoles][]*Var `` /* 142-byte string literal not displayed */ // true if a VertexSet has been added HasVertex bool `inactive:"+" desc:"true if a VertexSet has been added"` // true if PushSet has been added HasPush bool `inactive:"+" desc:"true if PushSet has been added"` // number of complete descriptor sets to construct -- each descriptor set can be bound to a specific pipeline at the start of rendering, and updated with specific Val instances to provide values for each Var used during rendering. If multiple rendering passes are performed in parallel, then each requires a separate descriptor set (e.g., typically associated with a different Frame in the swapchain), so this number should be increased. NDescs int `` /* 442-byte string literal not displayed */ // [view: -] our parent memory manager Mem *Memory `view:"-" desc:"our parent memory manager"` // if true, variables are statically bound to specific offsets in memory buffers, vs. dynamically bound offsets. Typically a compute shader operating on fixed data variables can use static binding, while graphics (e.g., vphong) requires dynamic binding to efficiently use the same shader code for multiple different values of the same variable type StaticVars bool `` /* 366-byte string literal not displayed */ // [view: -] vulkan descriptor layout based on vars VkDescLayout vk.PipelineLayout `view:"-" desc:"vulkan descriptor layout based on vars"` // [view: -] vulkan descriptor pool, allocated for NDescs and the different descriptor pools VkDescPool vk.DescriptorPool `view:"-" desc:"vulkan descriptor pool, allocated for NDescs and the different descriptor pools"` // allocated descriptor sets -- outer index is Vars.NDescs for different groups of descriptor sets, one of which can be bound to a pipeline at any given time. The inner dimension is per VarSet to cover the different sets of variable updated at different times or with different numbers of items. This variable is used for whole-pipline binding at start of rendering. VkDescSets [][]vk.DescriptorSet `` /* 372-byte string literal not displayed */ // [view: -] currently accumulating set of vals to write to update bindings -- initiated by BindValsStart, executed by BindValsEnd VkWriteVals []vk.WriteDescriptorSet `` /* 133-byte string literal not displayed */ // current descriptor collection index, set in BindValsStart BindDescIdx int `inactive:"-" desc:"current descriptor collection index, set in BindValsStart"` // dynamic offsets for Uniform and Storage variables, -- outer index is Vars.NDescs for different groups of descriptor sets, one of which can be bound to a pipeline at any given time, inner index is DynOffIdx on Var -- offsets are set when Val is bound via BindDynVal*. 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) BindDynValsAllIdx ¶ added in v1.0.32
BindDynValsAllIdx dynamically binds all uniform, storage values by index for all variables in all sets.
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.
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) BindStatVarsAll ¶ added in v1.0.32
func (vs *Vars) BindStatVarsAll()
BindStatVarsAll binds all static vars to their current values, for all Uniform and Storage variables, when using Static value binding.
All vals must be uploaded to Device memory 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) MemSizeStorage ¶ added in v1.0.32
func (*Vars) ModRegsStorage ¶ added in v1.0.32
ModRegStorage returns the regions of Storage Vals that have been modified
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
- cpuoptions_string.go
- debug.go
- device.go
- errors.go
- framebuffer.go
- glfw.go
- gpu.go
- gpu_linux.go
- image.go
- imageflags_string.go
- membuff.go
- memory.go
- memory_64.go
- optionstates_string.go
- opts.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