MCPcopy Create free account
hub / github.com/RenderKit/embree / initializeScene

Function initializeScene

tutorials/minimal/minimal_sycl.cpp:127–199  ·  view source on GitHub ↗

* Create a scene, which is a collection of geometry objects. Scenes are * what the intersect / occluded functions work on. You can think of a * scene as an acceleration structure, e.g. a bounding-volume hierarchy. * * Scenes, like devices, are reference-counted. */

Source from the content-addressed store, hash-verified

125 * Scenes, like devices, are reference-counted.
126 */
127RTCScene initializeScene(RTCDevice device, const sycl::queue& queue)
128{
129 RTCScene scene = rtcNewScene(device);
130
131 /*
132 * Create a triangle mesh geometry, and initialize a single triangle.
133 * You can look up geometry types in the API documentation to
134 * find out which type expects which buffers.
135 *
136 * We create buffers directly on the device, but you can also use
137 * shared buffers. For shared buffers, special care must be taken
138 * to ensure proper alignment and padding. This is described in
139 * more detail in the API documentation.
140 */
141 RTCGeometry geom = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_TRIANGLE);
142
143 float* vertices = alignedSYCLMallocDeviceReadOnly<float>(queue, 3 * 3, 16);
144
145 rtcSetSharedGeometryBuffer(geom,
146 RTC_BUFFER_TYPE_VERTEX,
147 0,
148 RTC_FORMAT_FLOAT3,
149 vertices,
150 0,
151 3*sizeof(float),
152 3);
153
154 unsigned* indices = alignedSYCLMallocDeviceReadOnly<unsigned>(queue, 3, 16);
155
156 rtcSetSharedGeometryBuffer(geom,
157 RTC_BUFFER_TYPE_INDEX,
158 0,
159 RTC_FORMAT_UINT3,
160 indices,
161 0,
162 3*sizeof(unsigned),
163 1);
164
165 if (vertices && indices)
166 {
167 vertices[0] = 0.f; vertices[1] = 0.f; vertices[2] = 0.f;
168 vertices[3] = 1.f; vertices[4] = 0.f; vertices[5] = 0.f;
169 vertices[6] = 0.f; vertices[7] = 1.f; vertices[8] = 0.f;
170
171 indices[0] = 0; indices[1] = 1; indices[2] = 2;
172 }
173
174 /*
175 * You must commit geometry objects when you are done setting them up,
176 * or you will not get any intersections.
177 */
178 rtcCommitGeometry(geom);
179
180 /*
181 * In rtcAttachGeometry(...), the scene takes ownership of the geom
182 * by increasing its reference count. This means that we don't have
183 * to hold on to the geom handle, and may release it. The geom object
184 * will be released automatically when the scene is destroyed.

Callers 1

mainFunction · 0.70

Calls 6

rtcNewSceneFunction · 0.85
rtcCommitGeometryFunction · 0.85
rtcAttachGeometryFunction · 0.85
rtcReleaseGeometryFunction · 0.85
rtcCommitSceneFunction · 0.85

Tested by

no test coverage detected