From 246465cea1310e9a771f22921e2cd1d1ffd5de43 Mon Sep 17 00:00:00 2001 From: Florian Reibold Date: Wed, 27 Nov 2024 16:22:17 +0100 Subject: [PATCH] [WIP] change API naming for buffers form 'Ex' to 'HostDevice' --- include/embree4/rtcore_buffer.h | 4 ++-- include/embree4/rtcore_geometry.h | 4 ++-- kernels/common/rtcore.cpp | 16 ++++++++-------- .../debug_device_memory_device.cpp | 12 ++++++------ tutorials/forest/forest_device.cpp | 14 +++++++------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/include/embree4/rtcore_buffer.h b/include/embree4/rtcore_buffer.h index 37d20a7c90..7abf0b5613 100644 --- a/include/embree4/rtcore_buffer.h +++ b/include/embree4/rtcore_buffer.h @@ -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); diff --git a/include/embree4/rtcore_geometry.h b/include/embree4/rtcore_geometry.h index d93302fab3..cd6bf7f21e 100644 --- a/include/embree4/rtcore_geometry.h +++ b/include/embree4/rtcore_geometry.h @@ -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); diff --git a/kernels/common/rtcore.cpp b/kernels/common/rtcore.cpp index f162d3d072..c2d0f4976f 100644 --- a/kernels/common/rtcore.cpp +++ b/kernels/common/rtcore.cpp @@ -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); @@ -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); @@ -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); @@ -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); diff --git a/tutorials/debug_device_memory/debug_device_memory_device.cpp b/tutorials/debug_device_memory/debug_device_memory_device.cpp index 96baa21ded..072610cc7c 100644 --- a/tutorials/debug_device_memory/debug_device_memory_device.cpp +++ b/tutorials/debug_device_memory/debug_device_memory_device.cpp @@ -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; @@ -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; @@ -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); @@ -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; @@ -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; @@ -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; diff --git a/tutorials/forest/forest_device.cpp b/tutorials/forest/forest_device.cpp index f36297bd10..b0804d535c 100644 --- a/tutorials/forest/forest_device.cpp +++ b/tutorials/forest/forest_device.cpp @@ -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); @@ -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); @@ -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);