- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Intel 4940MX - Windos10
Trying to load multiple geometries (sets of triangles) loaded from an opencascade mesh data source, my code gets stuck at rtcCommit(scene). I found similar issues mentioned in two posts:
https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/Crash-on-rtcCommit/td-p/1162504
https://community.intel.com/t5/Intel-Embree-Ray-Tracing-Kernels/rtcCommit-not-working/td-p/1017935
Here my code, which is very simple. ::init() and ::buildGeometryMesh() are methods of a class, which has also a ::perform( origin, direction) method, returning the intersection point of a ray cast from <origin>, along a direction <direction>
//! ---------------
//! function: init
//! details:
//! ---------------
bool raycaster::init(const std::map<int,occHandle(MeshVS_DataSourceCommon)>& mapOfMeshDS)
{
if(mapOfMeshDS.empty()) return false;
//! ----------------
//! load the meshes
//! ----------------
for(std::map<int,occHandle(MeshVS_DataSourceCommon)>::const_iterator it = mapOfMeshDS.cbegin(); it != mapOfMeshDS.cend(); it++)
{
if(it->second.IsNull()) continue;
unsigned int bodyIndex = (unsigned int)it->first;
RTCGeometry geom = buildGeometryMesh(it->second);
rtcAttachGeometryByID(scene,geom,bodyIndex);
rtcReleaseGeometry(geom);
}
cout<<"____tag00____"<<endl;
rtcCommitScene(scene);
cout<<"____tag01____"<<endl;
if(rtcGetDeviceError(device) != RTC_ERROR_NONE) { exit(1000); return false; }
return true;
}
//! ---------------------------------
//! function: buildGeometryMesh
//! details:
//! ---------------------------------
RTCGeometry raycaster::buildGeometryMesh(const occHandle(MeshVS_DataSourceCommon) &aMeshDS)
{
unsigned int NE = (unsigned int)aMeshDS->GetAllElements().Extent();
unsigned int NN = (unsigned int)aMeshDS->GetAllNodes().Extent();
RTCGeometry geom = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_TRIANGLE);
rtcSetGeometryBuildQuality(geom, RTC_BUILD_QUALITY_MEDIUM);
Vertex* vertices = (Vertex*) rtcSetNewGeometryBuffer(geom,RTC_BUFFER_TYPE_VERTEX,0,RTC_FORMAT_FLOAT3,sizeof(Vertex),NN);
[...] vertices are loaded
Triangle* triangles = (Triangle*) rtcSetNewGeometryBuffer(geom,RTC_BUFFER_TYPE_INDEX,0,RTC_FORMAT_UINT3,sizeof(Triangle),NE);
[...] triangles are loaded
}
rtcCommitGeometry(geom);
return geom;
}
I cannot figure out why the execution stops, or get stuck at scene commit.
As additional info: the same code, translated in a console application works correctly; it does not work if, after some modification, it is called within the main of the application the previous class belong to.
Any suggestion?
Thanks in advance
Giovanni
- Tags:
- raycasting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I might know what is going on. The problem is that QT seems to enable all floating point exceptions per default and this causes a problem for Embree as we often compute with "inf" values in vectors and that raises exceptions if certain exceptions flags are enabled. Could you try to pass "threads=1,float_exceptions=1" to rtcNewDevice, or alternatively invoke for each user thread that does something with Embree
_MM_SET_EXCEPTION_MASK(_MM_MASK_MASK);
to disable all floating point exceptions. If this works, remove "threads=1" to allow for multi-threaded BVH construction.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
it's hard to tell what goes wrong here. Couple of things that come to mind:
- Can you check whether you have no "inf/nan/.." values in your vertex data?
- Do you call rtcCommit from a single thread?
- Can you enable verbose cmd line output by passing "verbose=2" to rtcNewDevice, e.g. rtcNewDevice("verbose=2")?
- Try also to limit the number of threads used by the BVH builder, by rtcNewDevice("threads=1").
Maybe that helps to get further insight. If you could provide us a self-contained reproducer even better.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First of all thank you very much for your reply
I attached an image of two bodies, a cube and a cylinder put in close contact (pic00.PNG)
I retrieved from the two bodies two .stl meshes, than I used vertices and triangles
definitions for feeding the small code you have seen in my previous post.
The tessellations are internally created by an opencascade class (BRepIncrementalMesher)
and (in case, not in this one) "corrected" , if some degenerate triangle is present
(for complex models this often occurs)
It follows the list of node coordinates (just for showing you that no NaN, of Inf is present)
I plotted as an example the cloud of point for the "cylinder" (pic01.PNG) and draw
a few triangles by hand.
#vertices of "cube" mesh
-50 50 100
-50 50 0
-50 -50 0
-50 -50 100
50 50 100
50 50 0
50 -50 0
50 -50 100
#vectices of "cylinder mesh"
9.32141 23.1972 100
1.06103 24.9775 100
5.26698 24.4389 100
21.8254 12.1924 100
23.5719 8.3285 100
24.6404 4.22502 100
-11.2551 -22.3231 100
-14.8658 -20.0999 100
-18.0489 -17.2985 100
16.5169 18.7668 100
19.4509 15.7055 100
13.1077 21.2882 100
-24.9099 -2.12015 100
-18.0489 17.2985 100
-3.17545 -24.7975 100
-7.32057 -23.9042 100
24.6404 -4.22502 100
-22.7807 -10.2975 100
-24.1933 -6.29945 100
5.26698 -24.4389 100
1.06103 -24.9775 100
16.5169 -18.7668 100
-20.7127 -13.9994 100
9.32141 -23.1972 100
13.1077 -21.2882 100
-22.7807 10.2975 100
-20.7127 13.9994 100
-24.1933 6.29945 100
-24.9099 2.12015 100
19.4509 -15.7055 100
21.8254 -12.1924 100
-11.2551 22.3231 100
-14.8658 20.0999 100
-7.32057 23.9042 100
23.5719 -8.3285 100
-3.17545 24.7975 100
25 0 100
9.32141 23.1972 150
5.26698 24.4389 150
1.06103 24.9775 150
21.8254 12.1924 150
24.6404 4.22502 150
23.5719 8.3285 150
-11.2551 -22.3231 150
-18.0489 -17.2985 150
-14.8658 -20.0999 150
16.5169 18.7668 150
19.4509 15.7055 150
13.1077 21.2882 150
-18.0489 17.2985 150
-24.9099 -2.12015 150
-3.17545 -24.7975 150
-7.32057 -23.9042 150
24.6404 -4.22502 150
-24.1933 -6.29945 150
-22.7807 -10.2975 150
5.26698 -24.4389 150
1.06103 -24.9775 150
16.5169 -18.7668 150
-20.7127 -13.9994 150
9.32141 -23.1972 150
13.1077 -21.2882 150
-20.7127 13.9994 150
-22.7807 10.2975 150
-24.1933 6.29945 150
-24.9099 2.12015 150
19.4509 -15.7055 150
21.8254 -12.1924 150
-11.2551 22.3231 150
-14.8658 20.0999 150
-7.32057 23.9042 150
23.5719 -8.3285 150
-3.17545 24.7975 150
25 0 150
As you suggested I change the code line in which the device is created into
device = rtcNewDevice("threads=1, verbose=2");
Actually I do not know exactly if arguments should be separated by comma, but it seems
to work (obviously I tried also device = rtcNewDevice("threads=1"), and device = rtcNewDevice("verbose=2")
separately).
In the following the log. The code gets stuck @ building BVH8<triangle4v> using avx::BVH8BuilderSAH.
Thank in advance for your support
Regards
Giovanni
Embree Ray Tracing Kernels 3.13.0 (7c53133eb21424f7f0ae1e25bf357e358feaf6ab)
Compiler : Intel Compiler 19.0.8
Build : Release
Platform : Windows (64bit)
CPU : Core Haswell (GenuineIntel)
Threads : 4
ISA : XMM YMM SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 POPCNT AVX F16C RDRAND AVX2 FMA3 LZCNT BMI1 BMI2
Targets : SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AVXI AVX2
MXCSR : FTZ=1, DAZ=1
Config
Threads : 1
ISA : XMM YMM SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 POPCNT AVX F16C RDRAND AVX2 FMA3 LZCNT BMI1 BMI2
Targets : SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AVXI AVX2 (supported)
SSE2 SSE4.2 AVX AVX2 AVX512 (compile time enabled)
Features: intersection_filter
Tasking : TBB2021.2 TBB_header_interface_12020 TBB_lib_interface_12020
general:
build threads = 1
build user threads = 0
start_threads = 0
affinity = 0
frequency_level = simd256
hugepages = disabled
verbosity = 2
cache_size = 134.218 MB
max_spatial_split_replications = 1.2
triangles:
accel = default
builder = default
traverser = default
motion blur triangles:
accel = default
builder = default
traverser = default
quads:
accel = default
builder = default
traverser = default
motion blur quads:
accel = default
builder = default
traverser = default
line segments:
accel = default
builder = default
traverser = default
motion blur line segments:
accel = default
builder = default
traverser = default
hair:
accel = default
builder = default
traverser = default
motion blur hair:
accel = default
builder = default
traverser = default
subdivision surfaces:
accel = default
grids:
accel = default
builder = default
motion blur grids:
accel = default
builder = default
object_accel:
min_leaf_size = 1
max_leaf_size = 1
object_accel_mb:
min_leaf_size = 1
max_leaf_size = 1
segments: 0
-----------------------------------
flat_linear_curve: 0
round_linear_curve: 0
oriented_linear_curve: 0
flat_bezier_curve: 0
round_bezier_curve: 0
oriented_bezier_curve: 0
flat_bspline_curve: 0
round_bspline_curve: 0
oriented_bspline_curve: 0
flat_hermite_curve: 0
round_hermite_curve: 0
oriented_hermite_curve: 0
flat_catmull_rom_curve: 0
round_catmull_rom_curve: 0
oriented_catmull_rom_curve: 0
triangles: 158
quads: 0
grid: 0
subdivs: 0
sphere: 0
disc: 0
oriented_disc: 0
usergeom: 0
instance_cheap: 0
instance_expensive: 0
building BVH8<triangle4v> using avx::BVH8BuilderSAH ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I forgot to say that rtcCommit is called always from a single thread
Regards
Giovanni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Based on the logs the problem is definitely the BVH builder which seems to get stuck.
Just to verify: If you pass the "cube" and "cylinder" data (158 triangles total) as they are specified to Embree, rtcCommit hangs, correct?
Just to double-check sizeof(Vertex) == 12 and sizeof(Triangle) == 12, right?
Is it possible to get a binary drop of your app?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello, Thank you for your reply
I confirm rtcCommitScene hangs just after I've passed the geometries. Also in case I pass the single cube (for simplifying).
Then:
sizeOf(Vertex) is 12 and sizeOd(Triangle) is 12, since
since
struct Vertex { float x, y, z; };
struct Triangle { unsigned int v0, v1, v2; };
I would be happy if I could obtain a dump... Actually @@rtcCommitScene the interface freezes
no crash occurs, and I've to stop manually the application. In this case no dump is generated
by Windows WER (I checked if it was active, and it is so) in the dump files folder (the application
is launched from the deployment .exe, not from QtCreator)
As additional info I can say that If I run Qt in debug mode, I can obtain the two snapshots in
attachment, just before QtCreator crashes (!!). A floating point error is reported.
By the way, I'll try to generate a dump, since as you mention this is the straightforward
way for understating
Thank you in advance
Giovanni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, with binary drop I meant your application .exe (no source code), so that I can it on my machine with my version of Embree. This would be the ideal way to debug this.
Another suggestion: Could you add the following lines at the beginning of your program:
#include "xmmintrin.h"
#include "pmmintrin.h"
int main(int argc, char** argv)
{
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
_MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON);
...
}
That will flush denormals to zero. It's typically not required but the floating point exception in your code hints that something strange is going on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply and suggestions.
Actually I already added those lines, after reaing the verbose log of embree.
But nothing different happened.
In pic04,05,06 you will find a very small set of sequential instructions for using
the application: click on "open", go to "connection group", right click on "create automatic connection",
and this will trigger embree: the two meshes will be sent to embree, as I wrote in the previous post.
Warning 1: cubeAndCylinder.7z is the "model" to be opened; please rename it into "cubeAndCylinder.gil"
Warning 2: a folder will be created as pic07.PNG. It contains a file with settings.
I sent you the application exe in a private message
Thank you
Giovanni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I might know what is going on. The problem is that QT seems to enable all floating point exceptions per default and this causes a problem for Embree as we often compute with "inf" values in vectors and that raises exceptions if certain exceptions flags are enabled. Could you try to pass "threads=1,float_exceptions=1" to rtcNewDevice, or alternatively invoke for each user thread that does something with Embree
_MM_SET_EXCEPTION_MASK(_MM_MASK_MASK);
to disable all floating point exceptions. If this works, remove "threads=1" to allow for multi-threaded BVH construction.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page