2 Replies Latest reply on Mar 2, 2016 1:46 AM by dmitryk

    IntersectBatch is not intersecting at all - Firerays

    dimz

      /*DEVICE SETUP*/

      int gpuidx = -1;

      for (int idx = 0; idx < IntersectionApi::GetIntersectionDeviceCount(); ++idx) {

           IntersectionDeviceInfo const& devinfo(IntersectionApi::GetIntersectionDeviceInfo(idx));

           if (devinfo.type == IntersectionDeviceInfo::kGpu && devinfo.apis & IntersectionDeviceInfo::kOpenCl) {

                gpuidx = idx;

           }

      }

      int apitype = IntersectionDeviceInfo::kOpenCl;

      scene = IntersectionApi::Create(0, &gpuidx, &apitype, 1);

       

      /* SCENE SETUP */

      Shape *shape = scene->CreateMesh(&vertex[0].x, numVert, sizeof(vec4), &v->at(0), sizeof(int) * 3, nullptr, numTri/3);

      scene->AttachShape(shape);
      scene->Commit();

       

      /* BUFFERS SETUP */

      hitsGPU = scene->CreateBuffer(hitBufferRayCount * sizeof(Intersection), nullptr);

      raysGPU = scene->CreateBuffer(rayBufferRayCount * sizeof(ray), raysCPU);

       

      hitsCPU = (Intersection*)malloc(sizeof(Intersection)*hitBufferRayCount);

      raysCPU = (ray*)malloc(sizeof(ray)*rayBufferRayCount);

       

      m_Rays->getData(0, rayBufferRayCount, raysCPU);

       

      scene->IntersectBatch(raysGPU, hitBufferRayCount, hitsGPU, nullptr, &event);

      event->Wait();

       

      scene->MapBuffer(hitsGPU, MapType::kMapRead, 0, hitBufferRayCount*sizeof(Intersection), (void**)&hitsCPU, &event);

      event->Wait() ;

       

       

      The call of the IntersectionBatch function results in bad intersections.
      i dont know what i am doing wrong.