Closed paulmelis closed 4 years ago
Hmm, so even though ospExamples -s boxes
is working, when using the code below to construct the same boxes scene in my own code I get the same segfault, but only with the pathtracer (the scivis renderer works)
auto builder = ospray::testing::newBuilder("boxes");
ospray::testing::setParam(builder, "rendererType", state->renderer.c_str());
ospray::testing::commit(builder);
auto cpp_group = ospray::testing::buildGroup(builder);
ospray::testing::release(builder);
cpp_group.commit();
OSPGroup group = cpp_group.handle();
ospRetain(group);
instances.push_back(std::make_pair(group, glm::mat4(1.0f)));
Shouldn't this
be similar to this (i.e. set as data array instead of object)?
Yes, I caught this yesterday as I've been getting started porting our regression tests to the new ospray_testing
: the cornell_box
builder didn't call the base builder commit(), so it didn't get the right renderer type to make its materials.
I also made some more improvements to the C++ wrappers, so I'll just get that merged/pushed today without waiting on the regression test port (which will catch these things!).
Latest fixes/updates are now on release-2.0.x
.
Also note that cpp::Data()
now has additional constructors for std::vector
and std::array
, where the element type (OSPDataType
) is inferred at compile-time transparently.
...becomes just this:
Great, I'll update locally!
With respect to the C++ wrappers, I'm still using the C API at the moment, but it's starting to become more and more attractive to switch to the C++ one it seems.
With respect to the C++ wrappers, I'm still using the C API at the moment, but it's starting to become more and more attractive to switch to the C++ one it seems.
That's the goal! ;)
Is there anything specific to watch out for when mixing the C++ and C APIs? Would something like this work as expected?
OSPGroup group = cpp_group.handle();
ospRetain(group);
I'm still seeing the original segfault from above in my code, even though it is now gone in ospExamples
Retaining a group created by ospray_testing
should be all that's needed to keep it alive. I wonder if there's something else going on?
And is it still only a segfault with the pathtracer
? Or are there other situations that it fails?
I only see it with the path tracer. Here's a reproduction based on ospTutorial.cpp, replacing the scene geometry setup with the piece above for the builder and "boxes": builder.zip
Well this is a bit embarrassing: the issue isn't the C++ wrappers, but rather that the rendererType
parameter is set as a const char *
and not a std::string
. We didn't implement quite the exhaustive type compatibility with ospSetParam()
in ospray_testing
. Wrapping the value you set in a string constructor works: std::string(renderer_type)
.
And by embarrassing, I meant us! The ospray_testing
API silently doing the wrong thing isn't good here.
However, I'm not sure how to better address it. Basically the T
value passed as a parameter must exactly match what the underlying Builder
queries: a trade off for having flexible parameter types is that it is easier to get them wrong. :/
It gets worse, the original line I use in my code is this :grin:
ospray::testing::setParam(builder, "rendererType", state->renderer.c_str());
But okay, that's an easy fix
With the new
ospExamples
I get a segfault when run with-s cornell_box
:I don't see something obviously wrong in
apps/ospray_testing/builders/CornellBox.cpp
(but what do I know about using the API correctly :wink:). It works with the scivis renderer, so perhaps it's materials related? The other examples work for me, e.g. random spheres.