rtcNewBuffer(3)

πŸ’– rtcNewBuffer β€” the Embree Ray Tracing Kernels 4 era πŸ’–

okay bestie, pull up a chair because we're talking about rtcNewBuffer(3) from the Embree Ray Tracing Kernels 4 manual. she's a little function with a big job and honestly? iconic. ✨


🌸 NAME 🌸

rtcNewBuffer β€” creates a new data buffer πŸŽ€


✨ SYNOPSIS ✨

#include <embree4/rtcore.h>

RTCBuffer rtcNewBuffer(
  RTCDevice device,
  size_t byteSize
);

πŸ’… DESCRIPTION πŸ’…

so. rtcNewBuffer makes you a brand new data buffer object, sized exactly how many bytes you asked for (that's the byteSize argument, she's literally counting bytes for you 🫢), and she binds it to the device you hand her (the device argument, obvs).

here's the part you need to know: the buffer object is reference counted, and it starts life with an initial reference count of 1. so when you're done being obsessed with it, you let it go using the rtcReleaseBuffer API call. no lingering, no ghosting. 😌

the number of bytes you specified gets allocated at buffer construction time and deallocated when the buffer is destroyed. she's got a whole lifecycle. main character energy fr fr. πŸ‘‘


πŸ¦‹ the SYCL situation (iykyk) πŸ¦‹

if your device is an Embree SYCL device, then the buffer gets allocated using SYCL USM shared memory. translation bestie: the buffer can be accessed on the host and on the device (GPU), and the SYCL runtime will handle buffer transfers automatically. no manual lifting, the runtime just does it. slay. πŸ’«


πŸŽ€ want more control? πŸŽ€

for precise control over when memory is copied from host to device, you can also create a buffer using rtcNewBufferHostDevice. different function, different vibe, your choice. ✨


😭 EXIT STATUS 😭

if it flops? NULL is returned, and an error code gets set that you can query using rtcGetDeviceError. so like, check your errors, bestie. don't just assume. πŸ™ˆ


🌈 SEE ALSO 🌈

  • rtcNewBufferHostDevice
  • rtcRetainBuffer
  • rtcReleaseBuffer

and that's the whole page, no cap. πŸ¦‹βœ¨ this one came straight out of the Embree Ray Tracing Kernels 4 manual, filed under rtcNewBuffer(3), and it's giving reference-counted, byte-perfect, USM-shared-memory excellence. mwah. πŸ’‹ go build something gorgeous with it. πŸ’–πŸŒΈπŸŽ€

πŸ“¦ where this page comes from