Skip to content

Commit

Permalink
Merge branch 'release-1.4.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffamstutz committed Nov 28, 2017
2 parents 2161104 + d3759a1 commit b3895aa
Show file tree
Hide file tree
Showing 13 changed files with 697 additions and 403 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Version History
---------------

### Changes in v1.4.2:

- Several cleanups and bug fixes
- Fixed memory leak where the Embree BVH was never released when an
OSPModel was released
- Fixed a crash when API logging was enabled in certain situations
- Fixed a crash in MPI mode when creating lights without a renderer
- Fixed an issue with camera lens samples not initilized when spp <= 0
- Fixed an issue in ospExampleViewer when specifying multiple data files
- The C99 tutorial is now indicated as the default; the C++ wrappers do not
change the semantics of the API (memory management) so the C99 version
should be considered first when learning the API

### Changes in v1.4.1:

- Several cleanups and bug fixes
Expand Down
1,013 changes: 641 additions & 372 deletions README.md

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions apps/exampleViewer/ospExampleViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,11 @@ static inline void addImporterNodesToWorld(sg::Node& renderer)
ss << fn.name() << "_" << i << "_" << j << "_" << k;
auto importerNode_ptr = sg::createNode(ss.str(), "Importer")->nodeAs<sg::Importer>();;
auto &importerNode = *importerNode_ptr;
importerNode["fileName"] = fn.str();

auto &transform = world.createChild("transform_"+ss.str(), "Transform");
transform.add(importerNode_ptr);
importerNode["fileName"] = fn.str();

transform["scale"] = file.transform.scale;
transform["rotation"] = file.transform.rotation;
if (files.size() < 2 && animatedFiles.empty()) {
Expand All @@ -321,7 +323,6 @@ static inline void addImporterNodesToWorld(sg::Node& renderer)
animation.setChild("rotation", rotation.shared_from_this());
}

transform.add(importerNode_ptr);
renderer.traverse("verify");
renderer.traverse("commit");
auto bounds = importerNode_ptr->computeBounds();
Expand Down
6 changes: 6 additions & 0 deletions apps/exampleViewer/widgets/cameraManipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ namespace ospray {
float du = (to.x - from.x) * widget->rotateSpeed;
float dv = (to.y - from.y) * widget->rotateSpeed;

if (widget->upAnchored) {
const float theta = std::acos(dot(cam.up, normalize(cam.from-cam.at)));
// prevent instabilities at the poles by enforcing a minimum angle to up
dv = clamp(dv, theta-float(pi)+0.05f, theta-0.05f);
}

const vec3f pivot = cam.at;
AffineSpace3fa xfm
= AffineSpace3fa::translate(pivot)
Expand Down
6 changes: 3 additions & 3 deletions apps/ospTutorial.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* This is a small example tutorial how to use OSPRay in an application.
*
* On Linux build it in the build_directory with
* gcc -std=c99 ../apps/ospTutorial.c -I ../ospray/include -I .. ./libospray.so -Wl,-rpath,. -o ospTutorialC
* gcc -std=c99 ../apps/ospTutorial.c -I ../ospray/include -I .. ./libospray.so -Wl,-rpath,. -o ospTutorial
* On Windows build it in the build_directory\$Configuration with
* cl ..\..\apps\ospTutorial.c -I ..\..\ospray\include -I ..\.. ospray.lib
*/
Expand Down Expand Up @@ -146,7 +146,7 @@ int main(int argc, const char **argv) {

// access framebuffer and write its content as PPM file
const uint32_t * fb = (uint32_t*)ospMapFrameBuffer(framebuffer, OSP_FB_COLOR);
writePPM("firstFrameC.ppm", &imgSize, fb);
writePPM("firstFrame.ppm", &imgSize, fb);
ospUnmapFrameBuffer(fb, framebuffer);


Expand All @@ -155,7 +155,7 @@ int main(int argc, const char **argv) {
ospRenderFrame(framebuffer, renderer, OSP_FB_COLOR | OSP_FB_ACCUM);

fb = (uint32_t*)ospMapFrameBuffer(framebuffer, OSP_FB_COLOR);
writePPM("accumulatedFrameC.ppm", &imgSize, fb);
writePPM("accumulatedFrame.ppm", &imgSize, fb);
ospUnmapFrameBuffer(fb, framebuffer);

return 0;
Expand Down
4 changes: 2 additions & 2 deletions apps/ospTutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ int main(int argc, const char **argv) {

// access framebuffer and write its content as PPM file
uint32_t* fb = (uint32_t*)framebuffer.map(OSP_FB_COLOR);
writePPM("firstFrame.ppm", imgSize, fb);
writePPM("firstFrameCpp.ppm", imgSize, fb);
framebuffer.unmap(fb);


Expand All @@ -157,7 +157,7 @@ int main(int argc, const char **argv) {
renderer.renderFrame(framebuffer, OSP_FB_COLOR | OSP_FB_ACCUM);

fb = (uint32_t*)framebuffer.map(OSP_FB_COLOR);
writePPM("accumulatedFrame.ppm", imgSize, fb);
writePPM("accumulatedFrameCpp.ppm", imgSize, fb);
framebuffer.unmap(fb);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion cmake/ospray_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

SET(OSPRAY_VERSION_MAJOR 1)
SET(OSPRAY_VERSION_MINOR 4)
SET(OSPRAY_VERSION_PATCH 1)
SET(OSPRAY_VERSION_PATCH 2)
SET(OSPRAY_VERSION_GITHASH 0)
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
FIND_PACKAGE(Git)
Expand Down
1 change: 1 addition & 0 deletions modules/mpi/common/OSPWork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ namespace ospray {
{
Renderer *renderer = (Renderer*)rendererHandle.lookup();
Light *light = nullptr;
if (renderer)
light = renderer->createLight(type.c_str());

// No renderer present or the renderer doesn't intercept this
Expand Down
10 changes: 5 additions & 5 deletions ospray/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -448,11 +448,11 @@ ENDIF()
OSPRAY_CREATE_LIBRARY(ospray ${OSPRAY_SOURCES} LINK ${OSPRAY_LIBS} COMPONENT lib)

# build ospTutorial, for testing
ADD_EXECUTABLE(ospTutorial ../apps/ospTutorial.cpp)
TARGET_LINK_LIBRARIES(ospTutorial ospray ospray_common)
# C version
ADD_EXECUTABLE(ospTutorialC ../apps/ospTutorial.c)
TARGET_LINK_LIBRARIES(ospTutorialC ospray ospray_common)
ADD_EXECUTABLE(ospTutorial ../apps/ospTutorial.c)
TARGET_LINK_LIBRARIES(ospTutorial ospray)
# C++ version
ADD_EXECUTABLE(ospTutorialCpp ../apps/ospTutorial.cpp)
TARGET_LINK_LIBRARIES(ospTutorialCpp ospray)

##############################################################
# Configure find_package files
Expand Down
14 changes: 6 additions & 8 deletions ospray/api/Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@ namespace ospray {
// Helper functions ///////////////////////////////////////////////////////

template <typename OSTREAM_T>
static inline void installStatusMsgFunc(OSTREAM_T &stream)
static inline void installStatusMsgFunc(Device& device, OSTREAM_T &stream)
{
auto &device = currentDevice();
device.msg_fcn = [&](const char *msg){ stream << msg; };
}

template <typename OSTREAM_T>
static inline void installErrorMsgFunc(OSTREAM_T &stream)
static inline void installErrorMsgFunc(Device& device, OSTREAM_T &stream)
{
auto &device = currentDevice();
device.error_fcn = [&](OSPError e, const char *msg) {
stream << "OSPRAY ERROR [" << e << "]: " << msg << std::endl;
};
Expand Down Expand Up @@ -102,9 +100,9 @@ namespace ospray {

auto dst = OSPRAY_LOG_OUTPUT.value_or(getParamString("logOutput"));
if (dst == "cout")
installStatusMsgFunc(std::cout);
installStatusMsgFunc(*this, std::cout);
else if (dst == "cerr")
installStatusMsgFunc(std::cerr);
installStatusMsgFunc(*this, std::cerr);
else if (dst == "none")
msg_fcn = [](const char*){};

Expand All @@ -113,9 +111,9 @@ namespace ospray {

dst = OSPRAY_ERROR_OUTPUT.value_or(getParamString("errorOutput"));
if (dst == "cout")
installErrorMsgFunc(std::cout);
installErrorMsgFunc(*this, std::cout);
else if (dst == "cerr")
installErrorMsgFunc(std::cerr);
installErrorMsgFunc(*this, std::cerr);
else if (dst == "none")
error_fcn = [](OSPError, const char*){};

Expand Down
7 changes: 7 additions & 0 deletions ospray/common/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ namespace ospray {
this->ispcEquivalent = ispc::Model_create(this);
}

Model::~Model()
{
if (embreeSceneHandle)
rtcDeleteScene(embreeSceneHandle);
}

std::string Model::toString() const
{
return "ospray::Model";
Expand All @@ -48,6 +54,7 @@ namespace ospray {
RTCDevice embreeDevice = (RTCDevice)ospray_getEmbreeDevice();

ispc::Model_init(getIE(), embreeDevice, geometry.size(), volume.size());

embreeSceneHandle = (RTCScene)ispc::Model_getEmbreeSceneHandle(getIE());

bounds = empty;
Expand Down
2 changes: 1 addition & 1 deletion ospray/common/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace ospray {
struct OSPRAY_SDK_INTERFACE Model : public ManagedObject
{
Model();
virtual ~Model() override = default;
virtual ~Model() override;

//! \brief common function to help printf-debugging
virtual std::string toString() const override;
Expand Down
17 changes: 8 additions & 9 deletions ospray/render/Renderer.ispc
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ unmasked void Renderer_default_renderTile(uniform Renderer *uniform self,
uniform FrameBuffer *uniform fb = self->fb;
uniform Camera *uniform camera = self->camera;

float pixel_du = .5f, pixel_dv = .5f;
float lens_du = 0.f, lens_dv = 0.f;
uniform int32 spp = self->spp;
const uniform int32 spp = self->spp;

if (spp >= 1) {
ScreenSample screenSample;
Expand Down Expand Up @@ -97,8 +95,8 @@ unmasked void Renderer_default_renderTile(uniform Renderer *uniform self,
vec3f col = make_vec3f(0.f);
const uint32 pixel = z_order.xs[index] + (z_order.ys[index] * TILE_SIZE);
for (uniform uint32 s = 0; s < spp; s++) {
pixel_du = precomputedHalton2(startSampleID+s);
pixel_dv = precomputedHalton3(startSampleID+s);
const float pixel_du = precomputedHalton2(startSampleID+s);
const float pixel_dv = precomputedHalton3(startSampleID+s);
screenSample.sampleID.z = startSampleID+s;

cameraSample.screen.x = (screenSample.sampleID.x + pixel_du)
Expand All @@ -120,17 +118,18 @@ unmasked void Renderer_default_renderTile(uniform Renderer *uniform self,
setRGBAZ(tile,pixel,col,screenSample.alpha,screenSample.z);
}
} else {
if (tile.accumID >= 0) {
pixel_du = precomputedHalton2(tile.accumID);
pixel_dv = precomputedHalton3(tile.accumID);
}
const float pixel_du = precomputedHalton2(tile.accumID);
const float pixel_dv = precomputedHalton3(tile.accumID);

ScreenSample screenSample;
screenSample.sampleID.z = tile.accumID;
screenSample.z = inf;
screenSample.alpha = 0.f;

CameraSample cameraSample;
// TODO: fix correlations / better RNG
cameraSample.lens.x = precomputedHalton3(tile.accumID);
cameraSample.lens.y = precomputedHalton5(tile.accumID);

const uniform int blocks = tile.accumID > 0
|| spp > 0 ? 1 : min(1 << -2 * spp,
Expand Down

0 comments on commit b3895aa

Please sign in to comment.