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)
| 333 | // which must have the cmdBegin called already. Uses the GrabDepth Storage Buffer. |
| 334 | // call this after: sys.MemCmdEndSubmitWaitFree() |
| 335 | func (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. |
no test coverage detected