Skip to content

Commit

Permalink
[WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
freibold committed Oct 23, 2024
1 parent 69e5b33 commit d198df9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
11 changes: 6 additions & 5 deletions kernels/sycl/scene_sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,15 @@ void Scene::syncWithDevice(sycl::queue* queue_in)
geometries_data_device = (char*)device->malloc(geometry_data_byte_size, 16, EmbreeMemoryType::DEVICE);

Geometry** geometries_host = (Geometry**)device->malloc(sizeof(Geometry*)*geometries.size(), 16, EmbreeMemoryType::UNKNOWN);
std::memset(geometries_host, 0, sizeof(Geometry*) * geometries.size());
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]);
//}
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]);
}

queue.memcpy(geometries_data_device, geometries_data_host, geometry_data_byte_size);
queue.memcpy(geometries_device, geometries_host, sizeof(Geometry*) * geometries.size());
Expand Down
41 changes: 21 additions & 20 deletions tutorials/triangle_geometry/triangle_geometry_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,37 +248,37 @@ extern "C" void device_init (char* cfg)
/* create scene */
TutorialData_Constructor(&data);
g_scene = data.g_scene = rtcNewScene(g_device);
g_scene1 = rtcNewScene(g_device);
rtcSetSceneFlags(data.g_scene, RTC_SCENE_FLAG_PREFETCH_USM_SHARED_ON_GPU);
//g_scene1 = rtcNewScene(g_device);
//rtcSetSceneFlags(data.g_scene, RTC_SCENE_FLAG_PREFETCH_USM_SHARED_ON_GPU);

/* add cube */
addCube(g_scene1);
addCube(g_scene);

RTCGeometry inst = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_INSTANCE);
//RTCGeometry inst = rtcNewGeometry(g_device, RTC_GEOMETRY_TYPE_INSTANCE);

rtcSetGeometryTimeStepCount(inst, 2);
rtcSetGeometryInstancedScene(inst, g_scene1);
//rtcSetGeometryTimeStepCount(inst, 2);
//rtcSetGeometryInstancedScene(inst, g_scene1);

LinearSpace3fa xfm = one;
axfm0 = AffineSpace3fa(xfm,Vec3fa(0.f, 0.f, 0.f));
axfm1 = AffineSpace3fa(xfm,Vec3fa(3.f, 0.f, 0.f));
rtcSetGeometryTransform(inst,0,RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,(float*)&(axfm0.l.vx.x));
rtcSetGeometryTransform(inst,1,RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,(float*)&(axfm1.l.vx.x));

rtcAttachGeometry(data.g_scene,inst);
rtcReleaseGeometry(inst);
rtcCommitGeometry(inst);
//LinearSpace3fa xfm = one;
//axfm0 = AffineSpace3fa(xfm,Vec3fa(0.f, 0.f, 0.f));
//axfm1 = AffineSpace3fa(xfm,Vec3fa(3.f, 0.f, 0.f));
//rtcSetGeometryTransform(inst,0,RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,(float*)&(axfm0.l.vx.x));
//rtcSetGeometryTransform(inst,1,RTC_FORMAT_FLOAT4X4_COLUMN_MAJOR,(float*)&(axfm1.l.vx.x));
//
//rtcAttachGeometry(data.g_scene,inst);
//rtcReleaseGeometry(inst);
//rtcCommitGeometry(inst);

/* add ground plane */
addGroundPlane(data.g_scene);

/* commit changes to scene */
#if defined(EMBREE_SYCL_SUPPORT) && defined(SYCL_LANGUAGE_VERSION)
rtcCommitSceneWithQueue (g_scene1, *global_gpu_queue);
//rtcCommitSceneWithQueue (g_scene1, *global_gpu_queue);
rtcCommitSceneWithQueue (data.g_scene, *global_gpu_queue);
#else
rtcCommitScene (g_scene1);
rtcCommitScene (data.g_scene);
//rtcCommitScene (g_scene1);
#endif
}

Expand Down Expand Up @@ -319,10 +319,11 @@ void renderPixelStandard(const TutorialData& data,

/* shade pixels */
Vec3fa color = Vec3fa(0.0f);
if (ray.geomID != RTC_INVALID_GEOMETRY_ID || ray.instID[0] != RTC_INVALID_GEOMETRY_ID)
if (ray.geomID != RTC_INVALID_GEOMETRY_ID)
{
#if 1
Vec3fa diffuse = data.face_colors[ray.primID];
//Vec3fa diffuse = data.face_colors[ray.primID];
Vec3fa diffuse = Vec3fa(0.5f) + 0.5f * normalize(ray.Ng);
color = color + diffuse*0.5f;
Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1));

Expand All @@ -333,7 +334,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

0 comments on commit d198df9

Please sign in to comment.