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 Nov 6, 2024
1 parent 418ecd7 commit 8eb2895
Show file tree
Hide file tree
Showing 15 changed files with 827 additions and 262 deletions.
2 changes: 1 addition & 1 deletion kernels/common/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace embree
public:
/*! Buffer construction */
RawBufferView()
: ptr_ofs(nullptr), stride(0), num(0), format(RTC_FORMAT_UNDEFINED), modCounter(1), modified(true), userData(0) {}
: ptr_ofs(nullptr), dptr_ofs(nullptr), stride(0), num(0), format(RTC_FORMAT_UNDEFINED), modCounter(1), modified(true), userData(0) {}

public:
/*! sets the buffer view */
Expand Down
12 changes: 11 additions & 1 deletion kernels/common/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace embree
maxTimeSegments(0),
geometries_device(nullptr),
geometries_data_device(nullptr),
num_geometries_device(0),
taskGroup(new TaskGroup()),
progressInterface(this), progress_monitor_function(nullptr), progress_monitor_ptr(nullptr), progress_monitor_counter(0)
{
Expand All @@ -71,6 +72,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 +932,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()
39 changes: 39 additions & 0 deletions tutorials/debug_device_memory/debug_device_memory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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) {
try {
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);
} catch (std::exception& e ) {
std::cerr << "Exception caught: " << e.what() << std::endl;
}
}
Loading

0 comments on commit 8eb2895

Please sign in to comment.