Skip to content

Commit

Permalink
[WIP] change API naming for buffers form 'Ex' to 'HostDevice'
Browse files Browse the repository at this point in the history
  • Loading branch information
freibold committed Nov 27, 2024
1 parent 96782b9 commit 246465c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions include/embree4/rtcore_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ typedef struct RTCBufferTy* RTCBuffer;
/* Creates a new buffer. */
RTC_API RTCBuffer rtcNewBuffer(RTCDevice device, size_t byteSize);

RTC_API RTCBuffer rtcNewBufferEx(RTCDevice device, size_t byteSize);
RTC_API RTCBuffer rtcNewBufferHostDevice(RTCDevice device, size_t byteSize);

/* Creates a new shared buffer. */
RTC_API RTCBuffer rtcNewSharedBuffer(RTCDevice device, void* ptr, size_t byteSize);

/* Creates a new shared buffer. */
RTC_API RTCBuffer rtcNewSharedBufferEx(RTCDevice device, void* ptr, size_t byteSize);
RTC_API RTCBuffer rtcNewSharedBufferHostDevice(RTCDevice device, void* ptr, size_t byteSize);

RTC_API void rtcCommitBuffer(RTCBuffer buffer);

Expand Down
4 changes: 2 additions & 2 deletions include/embree4/rtcore_geometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ RTC_API void rtcSetGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type,
RTC_API 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);

/* Sets a shared host/device geometry buffer pair. */
RTC_API void rtcSetSharedGeometryBufferEx(RTCGeometry geometry, enum RTCBufferType bufferType, unsigned int slot, enum RTCFormat format, const void* ptr, const void* dptr, size_t byteOffset, size_t byteStride, size_t itemCount);
RTC_API void rtcSetSharedGeometryBufferHostDevice(RTCGeometry geometry, enum RTCBufferType bufferType, unsigned int slot, enum RTCFormat format, const void* ptr, const void* dptr, size_t byteOffset, size_t byteStride, size_t itemCount);

/* Creates and sets a new geometry buffer. */
RTC_API void* rtcSetNewGeometryBuffer(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount);

/* Creates and sets a new host/device geometry buffer pair. */
RTC_API void rtcSetNewGeometryBufferEx(RTCGeometry geometry, enum RTCBufferType bufferType, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount, void** ptr, void** dptr);
RTC_API void rtcSetNewGeometryBufferHostDevice(RTCGeometry geometry, enum RTCBufferType bufferType, unsigned int slot, enum RTCFormat format, size_t byteStride, size_t itemCount, void** ptr, void** dptr);

/* Returns the pointer to the data of a buffer. */
RTC_API void* rtcGetGeometryBufferData(RTCGeometry geometry, enum RTCBufferType type, unsigned int slot);
Expand Down
16 changes: 8 additions & 8 deletions kernels/common/rtcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ RTC_NAMESPACE_BEGIN;
return nullptr;
}

RTC_API RTCBuffer rtcNewBufferEx(RTCDevice hdevice, size_t byteSize)
RTC_API RTCBuffer rtcNewBufferHostDevice(RTCDevice hdevice, size_t byteSize)
{
RTC_CATCH_BEGIN;
RTC_TRACE(rtcNewBuffer);
RTC_TRACE(rtcNewBufferHostDevice);
RTC_VERIFY_HANDLE(hdevice);
RTC_ENTER_DEVICE(hdevice);
Buffer* buffer = new Buffer((Device*)hdevice, byteSize, nullptr, nullptr);
Expand All @@ -230,10 +230,10 @@ RTC_NAMESPACE_BEGIN;
return nullptr;
}

RTC_API RTCBuffer rtcNewSharedBufferEx(RTCDevice hdevice, void* ptr, size_t byteSize)
RTC_API RTCBuffer rtcNewSharedBufferHostDevice(RTCDevice hdevice, void* ptr, size_t byteSize)
{
RTC_CATCH_BEGIN;
RTC_TRACE(rtcNewSharedBuffer);
RTC_TRACE(rtcNewSharedBufferHostDevice);
RTC_VERIFY_HANDLE(hdevice);
RTC_ENTER_DEVICE(hdevice);
Buffer* buffer = new Buffer((Device*)hdevice, byteSize, ptr, nullptr);
Expand Down Expand Up @@ -1919,11 +1919,11 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
RTC_CATCH_END2(geometry);
}

RTC_API void rtcSetSharedGeometryBufferEx(RTCGeometry hgeometry, RTCBufferType type, unsigned int slot, RTCFormat format, const void* ptr, const void* dptr, size_t byteOffset, size_t byteStride, size_t itemCount)
RTC_API void rtcSetSharedGeometryBufferHostDevice(RTCGeometry hgeometry, RTCBufferType type, unsigned int slot, RTCFormat format, const void* ptr, const void* dptr, size_t byteOffset, size_t byteStride, size_t itemCount)
{
Geometry* geometry = (Geometry*) hgeometry;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcSetSharedGeometryBufferEx);
RTC_TRACE(rtcSetSharedGeometryBufferHostDevice);
RTC_VERIFY_HANDLE(hgeometry);
RTC_ENTER_DEVICE(hgeometry);

Expand Down Expand Up @@ -1971,11 +1971,11 @@ RTC_API void rtcSetGeometryTransform(RTCGeometry hgeometry, unsigned int timeSte
return nullptr;
}

RTC_API void rtcSetNewGeometryBufferEx(RTCGeometry hgeometry, RTCBufferType bufferType, unsigned int slot, RTCFormat format, size_t byteStride, size_t itemCount, void** ptr, void** dptr)
RTC_API void rtcSetNewGeometryBufferHostDevice(RTCGeometry hgeometry, RTCBufferType bufferType, unsigned int slot, RTCFormat format, size_t byteStride, size_t itemCount, void** ptr, void** dptr)
{
Geometry* geometry = (Geometry*) hgeometry;
RTC_CATCH_BEGIN;
RTC_TRACE(rtcSetNewGeometryBufferEx);
RTC_TRACE(rtcSetNewGeometryBufferHostDevice);
RTC_VERIFY_HANDLE(hgeometry);
RTC_ENTER_DEVICE(hgeometry);

Expand Down
12 changes: 6 additions & 6 deletions tutorials/debug_device_memory/debug_device_memory_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ unsigned int addCubeHostDevice (RTCScene scene, Vec3fa d)
/* set vertices and vertex colors */
Vertex* hVertices0;
Vertex* dVertices0;
rtcSetNewGeometryBufferEx(mesh, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, sizeof(Vertex), 8, (void **)&hVertices0, (void **)&dVertices0);
rtcSetNewGeometryBufferHostDevice(mesh, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, sizeof(Vertex), 8, (void **)&hVertices0, (void **)&dVertices0);
hVertices0[0].x = -1 + d.x; hVertices0[0].y = -1 + d.y; hVertices0[0].z = -1 + d.z;
hVertices0[1].x = -1 + d.x; hVertices0[1].y = -1 + d.y; hVertices0[1].z = +1 + d.z;
hVertices0[2].x = -1 + d.x; hVertices0[2].y = +1 + d.y; hVertices0[2].z = -1 + d.z;
Expand All @@ -45,7 +45,7 @@ unsigned int addCubeHostDevice (RTCScene scene, Vec3fa d)
rtcSetGeometryTimeStepCount(mesh, 2);
Vertex* hVertices1;
Vertex* dVertices1;
rtcSetNewGeometryBufferEx(mesh, RTC_BUFFER_TYPE_VERTEX, 1, RTC_FORMAT_FLOAT3, sizeof(Vertex), 8, (void **)&hVertices1, (void **)&dVertices1);
rtcSetNewGeometryBufferHostDevice(mesh, RTC_BUFFER_TYPE_VERTEX, 1, RTC_FORMAT_FLOAT3, sizeof(Vertex), 8, (void **)&hVertices1, (void **)&dVertices1);
hVertices1[0].x = -1 + d.x; hVertices1[0].y = -1 + 1.f + d.y; hVertices1[0].z = -1 + d.z;
hVertices1[1].x = -1 + d.x; hVertices1[1].y = -1 + 1.f + d.y; hVertices1[1].z = +1 + d.z;
hVertices1[2].x = -1 + d.x; hVertices1[2].y = +1 + 1.f + d.y; hVertices1[2].z = -1 + d.z;
Expand Down Expand Up @@ -87,7 +87,7 @@ unsigned int addCubeHostDevice (RTCScene scene, Vec3fa d)

#endif

rtcSetSharedGeometryBufferEx(mesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, hTriangles, dTriangles, 0, sizeof(Triangle), 12);
rtcSetSharedGeometryBufferHostDevice(mesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, hTriangles, dTriangles, 0, sizeof(Triangle), 12);
rtcCommitGeometry(mesh);

unsigned int geomID = rtcAttachGeometry(scene,mesh);
Expand Down Expand Up @@ -165,7 +165,7 @@ unsigned int addCubeBufferHostDevice (RTCScene scene, Vec3fa d)
RTCGeometry mesh = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_TRIANGLE);

/* set vertices and vertex colors */
RTCBuffer vertexBuffer0 = rtcNewBufferEx(g_device, 8 * sizeof(Vertex));
RTCBuffer vertexBuffer0 = rtcNewBufferHostDevice(g_device, 8 * sizeof(Vertex));
rtcSetGeometryBuffer(mesh, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, vertexBuffer0, 0, sizeof(Vertex), 8);
Vertex* hVertices0 = (Vertex*)rtcGetBufferData(vertexBuffer0);
hVertices0[0].x = -1 + d.x; hVertices0[0].y = -1 + d.y; hVertices0[0].z = -1 + d.z;
Expand All @@ -181,7 +181,7 @@ unsigned int addCubeBufferHostDevice (RTCScene scene, Vec3fa d)

#if defined(GEOMETRY_MOTION_BLUR)
rtcSetGeometryTimeStepCount(mesh, 2);
RTCBuffer vertexBuffer1 = rtcNewBufferEx(g_device, 8 * sizeof(Vertex));
RTCBuffer vertexBuffer1 = rtcNewBufferHostDevice(g_device, 8 * sizeof(Vertex));
rtcSetGeometryBuffer(mesh, RTC_BUFFER_TYPE_VERTEX, 1, RTC_FORMAT_FLOAT3, vertexBuffer1, 0, sizeof(Vertex), 8);
Vertex* hVertices1 = (Vertex*)rtcGetBufferData(vertexBuffer1);
hVertices1[0].x = -1 + d.x; hVertices1[0].y = -1 + 1.f + d.y; hVertices1[0].z = -1 + d.z;
Expand All @@ -199,7 +199,7 @@ unsigned int addCubeBufferHostDevice (RTCScene scene, Vec3fa d)
/* set triangles and face colors */

Triangle* hTriangles = data.hTrianglesBufferHostDevice = (Triangle*) alignedMalloc(12*sizeof(Triangle), 16);
RTCBuffer triangleBuffer = rtcNewSharedBufferEx(g_device, hTriangles, 12*sizeof(Triangle));
RTCBuffer triangleBuffer = rtcNewSharedBufferHostDevice(g_device, hTriangles, 12*sizeof(Triangle));
rtcSetGeometryBuffer(mesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, triangleBuffer, 0, sizeof(Triangle), 12);
hTriangles[ 0].v0 = 0; hTriangles[ 0].v1 = 1; hTriangles[ 0].v2 = 2;
hTriangles[ 1].v0 = 1; hTriangles[ 1].v1 = 3; hTriangles[ 1].v2 = 2;
Expand Down
14 changes: 7 additions & 7 deletions tutorials/forest/forest_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ unsigned int addTree(RTCScene scene_i, unsigned int tree_idx)
unsigned int num_triangles = tree_num_triangles[tree_idx];

/* set vertices and vertex colors */
RTCBuffer vertex_buffer = rtcNewSharedBufferEx(g_device, (void *)vertices, 3*num_vertices*sizeof(float));
RTCBuffer vertex_buffer = rtcNewSharedBufferHostDevice(g_device, (void *)vertices, 3*num_vertices*sizeof(float));
rtcSetGeometryBuffer(mesh, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, vertex_buffer, 0, 3*sizeof(float), num_vertices);
rtcCommitBuffer(vertex_buffer);
rtcReleaseBuffer(vertex_buffer);

RTCBuffer index_buffer = rtcNewSharedBufferEx(g_device, (void *)indices, 3*num_triangles*sizeof(unsigned int));
RTCBuffer index_buffer = rtcNewSharedBufferHostDevice(g_device, (void *)indices, 3*num_triangles*sizeof(unsigned int));
rtcSetGeometryBuffer(mesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, index_buffer, 0, 3*sizeof(unsigned int), num_triangles);
rtcCommitBuffer(index_buffer);
rtcReleaseBuffer(index_buffer);
data.tree_triangles[tree_idx] = (Triangle*)rtcGetBufferDataDevice(index_buffer);

/* create vertex color array */
RTCBuffer color_buffer = rtcNewSharedBufferEx(g_device, (void*)colors, 3*num_colors*sizeof(float));
RTCBuffer color_buffer = rtcNewSharedBufferHostDevice(g_device, (void*)colors, 3*num_colors*sizeof(float));
rtcSetGeometryVertexAttributeCount(mesh,1);
rtcSetGeometryBuffer(mesh, RTC_BUFFER_TYPE_VERTEX_ATTRIBUTE, 0, RTC_FORMAT_FLOAT3, color_buffer, 0, 3*sizeof(float), num_colors);
rtcCommitBuffer(color_buffer);
Expand All @@ -94,13 +94,13 @@ unsigned int addTerrain(RTCScene scene_i)
RTCGeometry mesh = rtcNewGeometry (g_device, RTC_GEOMETRY_TYPE_TRIANGLE);

/* set vertices */
RTCBuffer vertex_buffer = rtcNewSharedBufferEx(g_device, (void *)terrain_vertices, 3*terrain_num_vertices*sizeof(float));
RTCBuffer vertex_buffer = rtcNewSharedBufferHostDevice(g_device, (void *)terrain_vertices, 3*terrain_num_vertices*sizeof(float));
rtcSetGeometryBuffer(mesh, RTC_BUFFER_TYPE_VERTEX, 0, RTC_FORMAT_FLOAT3, vertex_buffer, 0, 3*sizeof(float), terrain_num_vertices);
rtcCommitBuffer(vertex_buffer);
rtcReleaseBuffer(vertex_buffer);

/* set triangles */
RTCBuffer index_buffer = rtcNewSharedBufferEx(g_device, (void *)terrain_indices, 3*terrain_num_triangles*sizeof(unsigned int));
RTCBuffer index_buffer = rtcNewSharedBufferHostDevice(g_device, (void *)terrain_indices, 3*terrain_num_triangles*sizeof(unsigned int));
rtcSetGeometryBuffer(mesh, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT3, index_buffer, 0, 3*sizeof(unsigned int), terrain_num_triangles);
rtcCommitBuffer(index_buffer);
rtcReleaseBuffer(index_buffer);
Expand Down Expand Up @@ -297,8 +297,8 @@ void rebuild_instances(size_t old_num_trees)
{
instance_array = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_INSTANCE_ARRAY);
rtcSetGeometryInstancedScenes(instance_array,(RTCScene*)scene_trees_selected,6);
rtcSetSharedGeometryBufferEx(instance_array, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, (void*)data.tree_ids_host, (void*)data.tree_ids_device, 0, sizeof(unsigned int), num_trees);
rtcSetSharedGeometryBufferEx(instance_array, RTC_BUFFER_TYPE_TRANSFORM, 0, RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR, (void*)data.tree_transforms_host, (void*)data.tree_transforms_device, 0, sizeof(AffineSpace3fa), num_trees);
rtcSetSharedGeometryBufferHostDevice(instance_array, RTC_BUFFER_TYPE_INDEX, 0, RTC_FORMAT_UINT, (void*)data.tree_ids_host, (void*)data.tree_ids_device, 0, sizeof(unsigned int), num_trees);
rtcSetSharedGeometryBufferHostDevice(instance_array, RTC_BUFFER_TYPE_TRANSFORM, 0, RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR, (void*)data.tree_transforms_host, (void*)data.tree_transforms_device, 0, sizeof(AffineSpace3fa), num_trees);
rtcAttachGeometry(data.g_scene,instance_array);
rtcReleaseGeometry(instance_array);
rtcCommitGeometry(instance_array);
Expand Down

0 comments on commit 246465c

Please sign in to comment.