<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Embree Reference Counting in Intel® Embree Ray Tracing Kernels</title>
    <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Embree-Reference-Counting/m-p/1676560#M1006</link>
    <description>&lt;P&gt;HI folks, the Embree documentation is rather unclear about how the reference counting is used as well as what increments the count. There are two situations shown in the following code block. First, when I attach a buffer to a geometry, does the buffers reference count get incremented? My impression based on the API is that I create the buffer, then attach it, then clean up my end, and the buffer will be deallocated once the geometry reference count falls to zero. The same applies to creating a geometry, attaching it to a scene, and then cleaning up my reference. Does the scene keep the geometry and the buffers attached to the geometry alive?&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;unsigned int CreateGeometry(RTCScene scene, std::span&amp;lt;unsigned int&amp;gt; indices, std::span&amp;lt;float&amp;gt; vertices) {
    auto device = rtcGetSceneDevice(scene);
    auto geom = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_TRIANGLE);
    
    auto index_buffer = rtcNewSharedBuffer(device, indices.data(), indices.size_bytes());
    rtcSetGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3,
        index_buffer, 0, sizeof(unsigned int) * 3, indices.size() / 3);
    rtcReleaseBuffer(index_buffer);
    
    auto vertex_buffer = rtcNewSharedBuffer(device, vertices.data(), vertices.size_bytes());
    rtcSetGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3,
        vertex_buffer, 0, sizeof(float) * 3, vertices.size() / 3);
    rtcReleaseBuffer(vertex_buffer);

    unsigned int id = rtcAttachGeometry(scene, geom);
    rtcReleaseGeometry(geom);
    return id;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Next up, after calling this `CreateGeometry` function, I call `rtcGetGeometry(scene, id)`. Does the geometry handle returned need to be released when I am done with it?&lt;/P&gt;</description>
    <pubDate>Thu, 20 Mar 2025 19:09:39 GMT</pubDate>
    <dc:creator>DBS4261</dc:creator>
    <dc:date>2025-03-20T19:09:39Z</dc:date>
    <item>
      <title>Embree Reference Counting</title>
      <link>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Embree-Reference-Counting/m-p/1676560#M1006</link>
      <description>&lt;P&gt;HI folks, the Embree documentation is rather unclear about how the reference counting is used as well as what increments the count. There are two situations shown in the following code block. First, when I attach a buffer to a geometry, does the buffers reference count get incremented? My impression based on the API is that I create the buffer, then attach it, then clean up my end, and the buffer will be deallocated once the geometry reference count falls to zero. The same applies to creating a geometry, attaching it to a scene, and then cleaning up my reference. Does the scene keep the geometry and the buffers attached to the geometry alive?&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;unsigned int CreateGeometry(RTCScene scene, std::span&amp;lt;unsigned int&amp;gt; indices, std::span&amp;lt;float&amp;gt; vertices) {
    auto device = rtcGetSceneDevice(scene);
    auto geom = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_TRIANGLE);
    
    auto index_buffer = rtcNewSharedBuffer(device, indices.data(), indices.size_bytes());
    rtcSetGeometryBuffer(geom, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3,
        index_buffer, 0, sizeof(unsigned int) * 3, indices.size() / 3);
    rtcReleaseBuffer(index_buffer);
    
    auto vertex_buffer = rtcNewSharedBuffer(device, vertices.data(), vertices.size_bytes());
    rtcSetGeometryBuffer(geom, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3,
        vertex_buffer, 0, sizeof(float) * 3, vertices.size() / 3);
    rtcReleaseBuffer(vertex_buffer);

    unsigned int id = rtcAttachGeometry(scene, geom);
    rtcReleaseGeometry(geom);
    return id;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Next up, after calling this `CreateGeometry` function, I call `rtcGetGeometry(scene, id)`. Does the geometry handle returned need to be released when I am done with it?&lt;/P&gt;</description>
      <pubDate>Thu, 20 Mar 2025 19:09:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Embree-Reference-Counting/m-p/1676560#M1006</guid>
      <dc:creator>DBS4261</dc:creator>
      <dc:date>2025-03-20T19:09:39Z</dc:date>
    </item>
  </channel>
</rss>

