Skip to content

Commit

Permalink
Port to Embree 4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
musicinmybrain committed Aug 26, 2024
1 parent 6d3b7c7 commit c8fec13
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 28 deletions.
16 changes: 8 additions & 8 deletions cmake/modules/FindEmbree.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
#=============================================================================

if (APPLE)
set (EMBREE_LIB_NAME libembree3.dylib)
set (EMBREE_LIB_NAME libembree4.dylib)
elseif (UNIX)
set (EMBREE_LIB_NAME libembree3.so)
set (EMBREE_LIB_NAME libembree4.so)
elseif (WIN32)
set (EMBREE_LIB_NAME embree3.lib)
set (EMBREE_LIB_NAME embree4.lib)
endif()

find_library(EMBREE_LIBRARY
Expand All @@ -39,20 +39,20 @@ find_library(EMBREE_LIBRARY
)

find_path(EMBREE_INCLUDE_DIR
embree3/rtcore.h
embree4/rtcore.h
HINTS
"${EMBREE_LOCATION}/include"
"$ENV{EMBREE_LOCATION}/include"
DOC
"Embree headers path"
)

if (EMBREE_INCLUDE_DIR AND EXISTS "${EMBREE_INCLUDE_DIR}/embree3/rtcore_version.h" )
file(STRINGS "${EMBREE_INCLUDE_DIR}/embree3/rtcore_version.h" TMP REGEX "^#define RTC_VERSION_MAJOR.*$")
if (EMBREE_INCLUDE_DIR AND EXISTS "${EMBREE_INCLUDE_DIR}/embree4/rtcore_version.h" )
file(STRINGS "${EMBREE_INCLUDE_DIR}/embree4/rtcore_version.h" TMP REGEX "^#define RTC_VERSION_MAJOR.*$")
string(REGEX MATCHALL "[0-9]+" MAJOR ${TMP})
file(STRINGS "${EMBREE_INCLUDE_DIR}/embree3/rtcore_version.h" TMP REGEX "^#define RTC_VERSION_MINOR.*$")
file(STRINGS "${EMBREE_INCLUDE_DIR}/embree4/rtcore_version.h" TMP REGEX "^#define RTC_VERSION_MINOR.*$")
string(REGEX MATCHALL "[0-9]+" MINOR ${TMP})
file(STRINGS "${EMBREE_INCLUDE_DIR}/embree3/rtcore_version.h" TMP REGEX "^#define RTC_VERSION_PATCH.*$")
file(STRINGS "${EMBREE_INCLUDE_DIR}/embree4/rtcore_version.h" TMP REGEX "^#define RTC_VERSION_PATCH.*$")
string(REGEX MATCHALL "[0-9]+" PATCH ${TMP})

set (EMBREE_VERSION ${MAJOR}.${MINOR}.${PATCH})
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/plugin/hdEmbree/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "pxr/base/gf/matrix4f.h"
#include "pxr/base/vt/array.h"

#include <embree3/rtcore.h>
#include <embree4/rtcore.h>

PXR_NAMESPACE_OPEN_SCOPE

Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/plugin/hdEmbree/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void HdEmbreeMesh::_EmbreeCullFaces(const RTCFilterFunctionNArguments* args)
default: break;
}
if (cull) {
// This is how you reject a hit in embree3 instead of setting
// This is how you reject a hit in embree3/4 instead of setting
// geomId to invalid on the ray
args->valid[i] = 0;
}
Expand Down
4 changes: 2 additions & 2 deletions pxr/imaging/plugin/hdEmbree/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

#include "pxr/imaging/plugin/hdEmbree/meshSamplers.h"

#include <embree3/rtcore.h>
#include <embree3/rtcore_ray.h>
#include <embree4/rtcore.h>
#include <embree4/rtcore_ray.h>

PXR_NAMESPACE_OPEN_SCOPE

Expand Down
4 changes: 2 additions & 2 deletions pxr/imaging/plugin/hdEmbree/meshSamplers.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "pxr/imaging/hd/meshUtil.h"
#include "pxr/base/vt/types.h"

#include <embree3/rtcore.h>
#include <embree3/rtcore_geometry.h>
#include <embree4/rtcore.h>
#include <embree4/rtcore_geometry.h>

#include <bitset>

Expand Down
6 changes: 3 additions & 3 deletions pxr/imaging/plugin/hdEmbree/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
#undef toupper
#endif
#endif // PXR_PYTHON_SUPPORT_ENABLED
#include <embree3/rtcore.h>
#include <embree3/rtcore_geometry.h>
#include <embree3/rtcore_ray.h>
#include <embree4/rtcore.h>
#include <embree4/rtcore_geometry.h>
#include <embree4/rtcore_ray.h>
#include <tbb/blocked_range.h>
#include <tbb/cache_aligned_allocator.h>
#include <tbb/concurrent_hash_map.h>
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/plugin/hdEmbree/renderDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "pxr/base/tf/staticTokens.h"

#include <mutex>
#include <embree3/rtcore.h>
#include <embree4/rtcore.h>

PXR_NAMESPACE_OPEN_SCOPE

Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/plugin/hdEmbree/renderParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "pxr/imaging/hd/renderDelegate.h"
#include "pxr/imaging/hd/renderThread.h"

#include <embree3/rtcore.h>
#include <embree4/rtcore.h>

PXR_NAMESPACE_OPEN_SCOPE

Expand Down
8 changes: 2 additions & 6 deletions pxr/imaging/plugin/hdEmbree/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,9 +637,7 @@ HdEmbreeRenderer::_TraceRay(unsigned int x, unsigned int y,
rayHit.ray.flags = 0;
_PopulateRayHit(&rayHit, origin, dir, 0.0f);
{
RTCIntersectContext context;
rtcInitIntersectContext(&context);
rtcIntersect1(_scene, &context, &rayHit);
rtcIntersect1(_scene, &rayHit);
//
// there is something odd about how this is used in Embree. Is it reversed
// here and then when it it used in
Expand Down Expand Up @@ -979,9 +977,7 @@ HdEmbreeRenderer::_ComputeAmbientOcclusion(GfVec3f const& position,
shadow.flags = 0;
_PopulateRay(&shadow, position, shadowDir, 0.001f);
{
RTCIntersectContext context;
rtcInitIntersectContext(&context);
rtcOccluded1(_scene,&context,&shadow);
rtcOccluded1(_scene,&shadow);
}

// Record this AO ray's contribution to the occlusion factor: a
Expand Down
4 changes: 2 additions & 2 deletions pxr/imaging/plugin/hdEmbree/renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "pxr/base/gf/matrix4d.h"
#include "pxr/base/gf/rect2i.h"

#include <embree3/rtcore.h>
#include <embree3/rtcore_ray.h>
#include <embree4/rtcore.h>
#include <embree4/rtcore_ray.h>

#include <random>
#include <atomic>
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/plugin/hdEmbree/testenv/testHdEmbree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "pxr/base/tf/errorMark.h"

#include <embree3/rtcore.h>
#include <embree4/rtcore.h>
#include <iostream>

PXR_NAMESPACE_USING_DIRECTIVE
Expand Down

0 comments on commit c8fec13

Please sign in to comment.