MCPcopy Create free account
hub / github.com/cogentcore/core / GrabDepthImage

Method GrabDepthImage

vgpu/render.go:335–360  ·  view source on GitHub ↗

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()

(dev vk.Device, cmd vk.CommandBuffer)

Source from the content-addressed store, hash-verified

333// which must have the cmdBegin called already. Uses the GrabDepth Storage Buffer.
334// call this after: sys.MemCmdEndSubmitWaitFree()
335func (rp *Render) GrabDepthImage(dev vk.Device, cmd vk.CommandBuffer) error {
336 nsamp := rp.Format.NSamples()
337 if nsamp > 1 {
338 err := errors.New("vgpu.Render.GrabDepthImage(): does not work if multisampling is > 1")
339 if Debug {
340 log.Println(err)
341 }
342 return err
343 }
344 rp.ConfigGrabDepth(dev) // ensure image grab setup
345 // first, prepare ImageGrab to receive copy from render image.
346 // apparently, the color attachment, with src flag already set, does not need this.
347
348 reg := vk.BufferImageCopy{BufferOffset: 0, BufferRowLength: 0, BufferImageHeight: 0}
349 reg.ImageSubresource.AspectMask = vk.ImageAspectFlags(vk.ImageAspectDepthBit)
350 reg.ImageSubresource.MipLevel = 0
351 reg.ImageSubresource.BaseArrayLayer = 0
352 reg.ImageSubresource.LayerCount = 1
353 reg.ImageOffset.X, reg.ImageOffset.Y, reg.ImageOffset.Z = 0, 0, 0
354 reg.ImageExtent.Width = uint32(rp.Format.Size.X)
355 reg.ImageExtent.Height = uint32(rp.Format.Size.Y)
356 reg.ImageExtent.Depth = 1
357
358 vk.CmdCopyImageToBuffer(cmd, rp.Depth.Image, vk.ImageLayoutTransferSrcOptimal, rp.GrabDepth.Host, 1, []vk.BufferImageCopy{reg})
359 return nil
360}
361
362// DepthImageArray returns the float values from the last GrabDepthImage call
363// automatically handles down-sampling from multisampling.

Callers 1

DepthImageMethod · 0.45

Calls 4

ConfigGrabDepthMethod · 0.95
NSamplesMethod · 0.80
PrintlnMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected