<commit_before>// ======================================================================== //
// Copyright 2009-2017 Intel Corporation                                    //
//                                                                          //
// Licensed under the Apache License, Version 2.0 (the "License");          //
// you may not use this file except in compliance with the License.         //
// You may obtain a copy of the License at                                  //
//                                                                          //
//     http://www.apache.org/licenses/LICENSE-2.0                           //
//                                                                          //
// Unless required by applicable law or agreed to in writing, software      //
// distributed under the License is distributed on an "AS IS" BASIS,        //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and      //
// limitations under the License.                                           //
// ======================================================================== //

#include "acceln.h"
#include "ray.h"
#include "../../include/embree2/rtcore_ray.h"
#include "../../common/algorithms/parallel_for.h"

namespace embree
{
  AccelN::AccelN () 
    : Accel(AccelData::TY_ACCELN), accels(nullptr), validAccels(nullptr), validIntersectorN(false) {}

  AccelN::~AccelN() 
  {
    for (size_t i=0; i<accels.size(); i++)
      delete accels[i];
  }

  void AccelN::add(Accel* accel) 
  {
    assert(accel);
    if (accels.size() == accels.max_size())
      throw_RTCError(RTC_UNKNOWN_ERROR,"internal error: AccelN too small");
    
    accels.push_back(accel);
  }
  
  void AccelN::intersect (void* ptr, RTCRay& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersect(ray,context);
  }

  void AccelN::intersect4 (const void* valid, void* ptr, RTCRay4& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersect4(valid,ray,context);
  }

  void AccelN::intersect8 (const void* valid, void* ptr, RTCRay8& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersect8(valid,ray,context);
  }

  void AccelN::intersect16 (const void* valid, void* ptr, RTCRay16& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersect16(valid,ray,context);
  }

  void AccelN::intersectN (void* ptr, void** ray, const size_t N, IntersectContext* context)
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersectN(ray,N,context);
  }

  void AccelN::occluded (void* ptr, RTCRay& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++) {
      This->validAccels[i]->occluded(ray,context); 
      if (ray.geomID == 0) break;
    }
  }

  void AccelN::occluded4 (const void* valid, void* ptr, RTCRay4& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++) {
      This->validAccels[i]->occluded4(valid,ray,context);
#if defined(__SSE2__)
      vbool4 valid0 = ((vbool4*)valid)[0];
      vbool4 hit0   = ((vint4*)ray.geomID)[0] == vint4(RTC_INVALID_GEOMETRY_ID));
      if (unlikely(none(valid0 & hit0))) break;
#endif
    }
  }

  void AccelN::occluded8 (const void* valid, void* ptr, RTCRay8& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;<commit_msg>rewrote early out for occlusion calls in acceln<commit_after>// ======================================================================== //
// Copyright 2009-2017 Intel Corporation                                    //
//                                                                          //
// Licensed under the Apache License, Version 2.0 (the "License");          //
// you may not use this file except in compliance with the License.         //
// You may obtain a copy of the License at                                  //
//                                                                          //
//     http://www.apache.org/licenses/LICENSE-2.0                           //
//                                                                          //
// Unless required by applicable law or agreed to in writing, software      //
// distributed under the License is distributed on an "AS IS" BASIS,        //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and      //
// limitations under the License.                                           //
// ======================================================================== //

#include "acceln.h"
#include "ray.h"
#include "../../include/embree2/rtcore_ray.h"
#include "../../common/algorithms/parallel_for.h"

namespace embree
{
  AccelN::AccelN () 
    : Accel(AccelData::TY_ACCELN), accels(nullptr), validAccels(nullptr), validIntersectorN(false) {}

  AccelN::~AccelN() 
  {
    for (size_t i=0; i<accels.size(); i++)
      delete accels[i];
  }

  void AccelN::add(Accel* accel) 
  {
    assert(accel);
    if (accels.size() == accels.max_size())
      throw_RTCError(RTC_UNKNOWN_ERROR,"internal error: AccelN too small");
    
    accels.push_back(accel);
  }
  
  void AccelN::intersect (void* ptr, RTCRay& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersect(ray,context);
  }

  void AccelN::intersect4 (const void* valid, void* ptr, RTCRay4& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersect4(valid,ray,context);
  }

  void AccelN::intersect8 (const void* valid, void* ptr, RTCRay8& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersect8(valid,ray,context);
  }

  void AccelN::intersect16 (const void* valid, void* ptr, RTCRay16& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersect16(valid,ray,context);
  }

  void AccelN::intersectN (void* ptr, void** ray, const size_t N, IntersectContext* context)
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++)
      This->validAccels[i]->intersectN(ray,N,context);
  }

  void AccelN::occluded (void* ptr, RTCRay& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++) {
      This->validAccels[i]->occluded(ray,context); 
      if (ray.geomID == 0) break; // ray.geomID != FIXME: RTC_INVALID_GEOMETRY_ID ?
    }
  }

  void AccelN::occluded4 (const void* valid, void* ptr, RTCRay4& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
    for (size_t i=0; i<This->validAccels.size(); i++) {
      This->validAccels[i]->occluded4(valid,ray,context);
#if defined(__SSE2__)
      vbool4 valid0 = ((vbool4*)valid)[0];
      vbool4 hit0   = ((vint4*)ray.geomID)[0] == vint4(RTC_INVALID_GEOMETRY_ID);
      if (unlikely(none(valid0 & hit0))) break;
#endif
    }
  }

  void AccelN::occluded8 (const void* valid, void* ptr, RTCRay8& ray, IntersectContext* context) 
  {
    AccelN* This = (AccelN*)ptr;
{'fraction_non_alphanumeric': 0.17720877170744073, 'fraction_numerical': 0.012929395360628723, 'mean_word_length': 2.4529540481400436, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4860160', 'n_tokens_mistral': 2576, 'n_tokens_neox': 2485, 'n_words': 579}