rtcNewSha...ostDevice(3)
π rtcNewSharedBufferHostDevice β from the Embree Ray Tracing Kernels 4 manual, bestie π
okay so real talk, this page lives in the Embree Ray Tracing Kernels 4 manual (you know, rtcNewSha...ostDevice(3), the title got chopped but we know her π). And she is actually so useful, so let's get into it, no cap.
β¨ NAME β¨
rtcNewSharedBufferHostDevice β bestie this creates a brand new shared data buffer, with a managed copy of the buffer just vibing in device memory π
πΈ SYNOPSIS πΈ
#include <embree4/rtcore.h>
RTCBuffer rtcNewSharedBufferHostDevice(
RTCDevice device,
void* ptr,
size_t byteSize
);
π DESCRIPTION π
so. rtcNewSharedBufferHostDevice makes you a new shared data buffer object, and it binds it to the device you pass in (that's the device argument, obviously π).
Girl, the buffer object is reference counted, starting at an initial reference count of 1. When you're done with it, release it with rtcReleaseBuffer. periodt.
At construction time you hand over a pointer to your own user-managed buffer data (the ptr argument) plus its size in bytes (the byteSize argument) and that's what makes the buffer. π«Ά
Big important thing bestie, listen: at buffer construction time no buffer data is allocated on the host. None. Zero. The buffer data your application provided is what gets used. Instead, an equal sized memory allocation is created over on the device. Two places, one buffer, iconic behaviour honestly β¨
β οΈ The buffer data must remain valid for as long as the buffer may be used, and you (yes you, the user) are responsible for freeing the buffer data when it's no longer required. Do not skip this. Do not be cute about it. π
Also the data pointer (the ptr argument) must be aligned to 4 bytes. If it isn't, rtcNewSharedBufferHostDevice will straight up fail. Alignment check is not a vibe check, she does not negotiate π
And if you want to sync your buffer content over to the device, that's what rtcCommitBuffer is for. Use her. π
π¦ EXIT STATUS π¦
If it fails, you get NULL back and an error code gets set β and you can go query that error code with rtcGetDeviceError. slay (derogatory, because something went wrong, but now you know how to find out π)
π SEE ALSO π
- [rtcNewSharedBuffer]
- [rtcCommitBuffer]
- [rtcRetainBuffer]
- [rtcReleaseBuffer]
and that's the whole page bestie, you understood it, you ate that π
later bestie π β this was the rtcNewSha...ostDevice(3) page from Embree Ray Tracing Kernels 4. go build something gorgeous with your 4-byte-aligned buffer β¨
π¦ where this page comes from
- ubuntu stonking: libembree-dev 4.4.1+dfsg-2ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms