Skip to content

Commit

Permalink
[WIP] add debug tutorial and restore state of other tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
freibold committed Oct 31, 2024
1 parent 418ecd7 commit 44e6441
Show file tree
Hide file tree
Showing 14 changed files with 821 additions and 261 deletions.
11 changes: 10 additions & 1 deletion kernels/common/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ namespace embree

Scene::~Scene() noexcept
{
#if defined(EMBREE_SYCL_SUPPORT)
if (geometries_data_device) {
device->free(geometries_data_device);
}
if (geometries_device) {
device->free(geometries_device);
}
#endif

device->refDec();
}

Expand Down Expand Up @@ -922,7 +931,7 @@ namespace embree
}
catch (...) {
accels_clear();
Lock<MutexSys> lock(taskGroup->schedulerMutex);, *global_gpu_queue
Lock<MutexSys> lock(taskGroup->schedulerMutex);
taskGroup->scheduler = nullptr;
throw;
}
Expand Down
4 changes: 2 additions & 2 deletions kernels/common/scene_grid_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ namespace embree
interpolate_impl<4>(args);
}

#if defined(EMBREE_SYCL_SUPPORT)

size_t GridMesh::getGeometryDataDeviceByteSize() const {
size_t byte_size = sizeof(GridMesh);
byte_size += numTimeSteps * sizeof(BufferView<Vec3fa>);
Expand All @@ -213,8 +215,6 @@ namespace embree
return 16 * ((byte_size + 15) / 16);
}

#if defined(EMBREE_SYCL_SUPPORT)

void GridMesh::convertToDeviceRepresentation(size_t offset, char* data_host, char* data_device) const {
GridMesh* mesh = (GridMesh*)(data_host + offset);
std::memcpy(data_host + offset, (void*)this, sizeof(GridMesh));
Expand Down
5 changes: 5 additions & 0 deletions kernels/common/scene_grid_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ namespace embree
void commit();
bool verify();
void interpolate(const RTCInterpolateArguments* const args);

#if defined(EMBREE_SYCL_SUPPORT)

size_t getGeometryDataDeviceByteSize() const;
void convertToDeviceRepresentation(size_t offset, char* data_host, char* data_device) const;

#endif

template<int N>
void interpolate_impl(const RTCInterpolateArguments* const args)
{
Expand Down
3 changes: 3 additions & 0 deletions kernels/sycl/scene_sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ void Scene::syncWithDevice(sycl::queue* queue_in)
Geometry** geometries_host = (Geometry**)device->malloc(sizeof(Geometry*)*geometries.size(), 16, EmbreeMemoryType::UNKNOWN);
char* geometries_data_host = (char*)device->malloc(geometry_data_byte_size, 16, EmbreeMemoryType::UNKNOWN);

std::memset(geometries_host, 0, sizeof(Geometry*) * geometries.size());
std::memset(geometries_data_host, 0, geometry_data_byte_size);

for (size_t i = 0; i < geometries.size(); ++i) {
geometries[i]->convertToDeviceRepresentation(offsets[i], geometries_data_host, geometries_data_device);
geometries_host[i] = (Geometry*)(geometries_data_device + offsets[i]);
Expand Down
1 change: 1 addition & 0 deletions tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ ADD_SUBDIRECTORY(next_hit)
ADD_SUBDIRECTORY(multiscene_geometry)
ADD_SUBDIRECTORY(ray_mask)
ADD_SUBDIRECTORY(forest)
ADD_SUBDIRECTORY(debug_device_memory)

ADD_SUBDIRECTORY(embree_tests)

Expand Down
2 changes: 1 addition & 1 deletion tutorials/curve_geometry/curve_geometry_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void renderPixelStandard(const TutorialData& data,
RTCOccludedArguments sargs;
rtcInitOccludedArguments(&sargs);
sargs.feature_mask = (RTCFeatureFlags) (FEATURE_MASK);
//rtcOccluded1(data.g_scene,RTCRay_(shadow),&sargs);
rtcOccluded1(data.g_scene,RTCRay_(shadow),&sargs);
RayStats_addShadowRay(stats);

/* add light contribution */
Expand Down
11 changes: 11 additions & 0 deletions tutorials/debug_device_memory/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Copyright 2009-2021 Intel Corporation
## SPDX-License-Identifier: Apache-2.0

IF (EMBREE_GEOMETRY_TRIANGLE)

INCLUDE(tutorial)
ADD_TUTORIAL(debug_device_memory)
ADD_TUTORIAL_ISPC(debug_device_memory)
ADD_TUTORIAL_SYCL(debug_device_memory)

ENDIF()
35 changes: 35 additions & 0 deletions tutorials/debug_device_memory/debug_device_memory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "../common/tutorial/tutorial.h"
#include "../common/tutorial/benchmark_render.h"

#if defined(EMBREE_SYCL_TUTORIAL)
# define NAME "debug_device_memory_sycl"
# define FEATURES FEATURE_RTCORE | FEATURE_SYCL
#else
# define NAME "debug_device_memory"
# define FEATURES FEATURE_RTCORE
#endif

namespace embree
{
struct Tutorial : public TutorialApplication
{
Tutorial()
: TutorialApplication(NAME,FEATURES)
{
/* set default camera */
camera.from = Vec3fa(1.5f,1.5f,-1.5f);
camera.to = Vec3fa(0.0f,0.0f,0.0f);
}
};

}

int main(int argc, char** argv) {
if (embree::TutorialBenchmark::benchmark(argc, argv)) {
return embree::TutorialBenchmark(embree::renderBenchFunc<embree::Tutorial>).main(argc, argv, "debug_device_memory");
}
return embree::Tutorial().main(argc,argv);
}
Loading

0 comments on commit 44e6441

Please sign in to comment.