// Copyright 2009-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

#include "../common/tutorial/tutorial_device.isph"

struct Sphere
{
  ALIGNED_STRUCT_(16)
  Vec3f p;                      //!< position of the sphere
  float r;                      //!< radius of the sphere
  RTCGeometry geometry;
  uniform unsigned int geomID;
};

struct TutorialData
{  
  RTCScene g_scene;
  RTCScene g_scene0;
  uniform Sphere* uniform g_spheres;
  int g_spp;
  bool g_motion_blur;
  float g_time;
  float g_shutter_close;

  /* accumulation buffer */
  uniform Vec3ff* g_accu;
  uniform unsigned int g_accu_width;
  uniform unsigned int g_accu_height;
  uniform unsigned int g_accu_count;
  uniform Vec3f g_accu_vx;
  uniform Vec3f g_accu_vy;
  uniform Vec3f g_accu_vz;
  uniform Vec3f g_accu_p;
};

#if __SYCL_COMPILER_VERSION >= 20210801
}
namespace sycl {
  template<> struct is_device_copyable<embree::TutorialData> : std::true_type {};
  template<> struct is_device_copyable<const embree::TutorialData> : std::true_type {};
}
namespace embree {
#endif

inline void TutorialData_Constructor(uniform TutorialData* uniform This)
{
  This->g_scene = NULL;
  This->g_scene0 = NULL;
  This->g_spheres = NULL;
  This->g_spp = 0;
  This->g_motion_blur = true;
  This->g_time = 0.f;
  This->g_shutter_close = 0.f;
  This->g_accu = NULL;
  This->g_accu_width = 0;
  This->g_accu_height = 0;
  This->g_accu_count = 0;
  This->g_accu_vx = make_Vec3f(0.0f);
  This->g_accu_vy = make_Vec3f(0.0f);
  This->g_accu_vz = make_Vec3f(0.0f);
  This->g_accu_p  = make_Vec3f(0.0f);
}

inline void TutorialData_Destructor(uniform TutorialData* uniform This)
{
  rtcReleaseScene (This->g_scene); This->g_scene = NULL;
  rtcReleaseScene (This->g_scene0); This->g_scene0 = NULL;
  delete[] This->g_spheres; This->g_spheres = NULL;
  delete[] This->g_accu; This-> g_accu = NULL;

  This->g_accu_width = 0;
  This->g_accu_height = 0;
  This->g_accu_count = 0;
}
