From d198df98b6784a790c6fc7ad740268ceb8fdbc67 Mon Sep 17 00:00:00 2001 From: Florian Reibold Date: Wed, 23 Oct 2024 17:24:22 +0200 Subject: [PATCH] [WIP] --- kernels/sycl/scene_sycl.cpp | 11 ++--- .../triangle_geometry_device.cpp | 41 ++++++++++--------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/kernels/sycl/scene_sycl.cpp b/kernels/sycl/scene_sycl.cpp index dfce6a3836..9bc89da8d1 100644 --- a/kernels/sycl/scene_sycl.cpp +++ b/kernels/sycl/scene_sycl.cpp @@ -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()); diff --git a/tutorials/triangle_geometry/triangle_geometry_device.cpp b/tutorials/triangle_geometry/triangle_geometry_device.cpp index 7784a83837..8187f2d6fe 100644 --- a/tutorials/triangle_geometry/triangle_geometry_device.cpp +++ b/tutorials/triangle_geometry/triangle_geometry_device.cpp @@ -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 } @@ -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)); @@ -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 */