rtcSetSha...tryBuffer(3)

πŸ’– rtcSetSha...tryBuffer(3) β€” Embree Ray Tracing Kernels 4 πŸ’–

okay bestie, welcome to the Embree manual, section 3, and today's main character is rtcSetSha...tryBuffer(3). yes the title is doing that little abbreviated thing, it's giving mysterious, it's giving ellipsis-core, we love her. πŸŽ€


✨ NAME ✨

rtcSetSharedGeometryBuffer β€” assigns a view of a shared data buffer to a geometry

like. she literally just hands your geometry a little window into a buffer you already own. no copying, no drama. 🫢


✨ SYNOPSIS ✨

#include <embree4/rtcore.h>

void rtcSetSharedGeometryBuffer(
  RTCGeometry geometry,
  enum RTCBufferType type,
  unsigned int slot,
  enum RTCFormat format,
  const void* ptr,
  size_t byteOffset,
  size_t byteStride,
  size_t itemCount
);

✨ DESCRIPTION ✨

so the rtcSetSharedGeometryBuffer function binds a view of a shared, user-managed data buffer β€” that's the ptr argument, bestie, it's YOUR memory, not Embree's β€” to a geometry buffer type and slot (yep, the type and slot arguments) of the geometry you picked out (geometry argument). πŸ’…

you get to specify all the little details too:

  • where the first buffer element starts, in bytes β€” that's byteOffset
  • the byte stride between individual buffer elements β€” that's byteStride
  • the format of the buffer elements β€” that's format
  • and how many elements to bind β€” that's itemCount
ok now the important part, no cap: the start address (byteOffset argument) and the stride (byteStride argument) must both be aligned to 4 bytes. if they're not, the rtcSetSharedGeometryBuffer function will fail. periodt. 😭

the buffer data has to stay valid for as long as the buffer might be used, and you β€” yes you, the user β€” are responsible for freeing that buffer data once it's no longer required. it's your child now. 🧚

if you're using a SYCL Embree device, then ptr must be allocated using SYCL USM shared memory so it's actually accessible on the device. alternatively, the function rtcSetSharedGeometryBufferHostDevice exists so you can pass an explicitly managed host/device buffer pair instead. slay, options. 🌈

sharing buffers can significantly reduce the memory your application needs, so like, we genuinely recommend using this feature. and when you enable the RTC_SCENE_FLAG_COMPACT scene flag, the spatial index structures index directly into the vertex buffer, which means even higher memory savings. it's giving efficient. it's giving iconic. πŸ‘‘


✨ EXIT STATUS ✨

if it fails, an error code gets set, and you can go query it with rtcGetDeviceError. go check on her, she'll tell you what happened. πŸ”


✨ SEE ALSO ✨

  • rtcSetSharedGeometryBufferHostDevice
  • rtcSetGeometryBuffer
  • rtcSetNewGeometryBuffer

and that's the whole vibe check bestie!! πŸ’œ this little love letter comes to you straight from the Embree Ray Tracing Kernels 4 manual, page rtcSetSha...tryBuffer(3) β€” go forth and share those buffers responsibly, mwah πŸ“πŸ’–βœ¨

πŸ“¦ where this page comes from