godot/thirdparty/embree/include/embree4/rtcore_common.h

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

#pragma once

#include <stddef.h>
#include <sys/types.h>
#include <stdbool.h>

#include "rtcore_config.h"

RTC_NAMESPACE_BEGIN

#if defined(_WIN32)
#if defined(_M_X64) || defined(_M_ARM64)
typedef long long ssize_t;
#else
typedef int ssize_t;
#endif
#endif

#if defined(_WIN32) && !defined(__MINGW32__)
#define RTC_ALIGN
#else
#define RTC_ALIGN(...)
#endif

#if !defined (RTC_DEPRECATED)
#ifdef __GNUC__
  #define RTC_DEPRECATED
#elif defined(_MSC_VER)
  #define RTC_DEPRECATED
#else
  #define RTC_DEPRECATED
#endif
#endif

#if defined(_WIN32) 
#define RTC_FORCEINLINE
#else
#define RTC_FORCEINLINE
#endif

#if defined(__cplusplus)
#define RTC_OPTIONAL_ARGUMENT
#else
#define RTC_OPTIONAL_ARGUMENT
#endif

/* Invalid geometry ID */
#define RTC_INVALID_GEOMETRY_ID

/* Maximum number of time steps */
#define RTC_MAX_TIME_STEP_COUNT

/* Formats of buffers and other data structures */
enum RTCFormat
{};

/* Build quality levels */
enum RTCBuildQuality
{};

/* Axis-aligned bounding box representation */
struct RTC_ALIGN(16) RTCBounds
{};

/* Linear axis-aligned bounding box representation */
struct RTC_ALIGN(16) RTCLinearBounds
{};

/* Feature flags for SYCL specialization constants */
enum RTCFeatureFlags
{};

/* Ray query flags */
enum RTCRayQueryFlags
{};

/* Arguments for RTCFilterFunctionN */
struct RTCFilterFunctionNArguments
{};

/* Filter callback function */
RTCFilterFunctionN;

/* Intersection callback function */
struct RTCIntersectFunctionNArguments;
RTCIntersectFunctionN;

/* Occlusion callback function */
struct RTCOccludedFunctionNArguments;
RTCOccludedFunctionN;

/* Ray query context passed to intersect/occluded calls */
struct RTCRayQueryContext
{};

/* Initializes an ray query context. */
RTC_FORCEINLINE void rtcInitRayQueryContext(struct RTCRayQueryContext* context)
{}

/* Point query structure for closest point query */
struct RTC_ALIGN(16) RTCPointQuery 
{};

/* Structure of a packet of 4 query points */
struct RTC_ALIGN(16) RTCPointQuery4
{};

/* Structure of a packet of 8 query points */
struct RTC_ALIGN(32) RTCPointQuery8
{};

/* Structure of a packet of 16 query points */
struct RTC_ALIGN(64) RTCPointQuery16
{};

struct RTCPointQueryN;

struct RTC_ALIGN(16) RTCPointQueryContext
{};

/* Initializes an ray query context. */
RTC_FORCEINLINE void rtcInitPointQueryContext(struct RTCPointQueryContext* context)
{}

struct RTC_ALIGN(16) RTCPointQueryFunctionArguments
{};

RTCPointQueryFunction;

#if defined(EMBREE_SYCL_SUPPORT) && defined(SYCL_LANGUAGE_VERSION)

/* returns function pointer to be usable in SYCL kernel */
template<auto F>
inline decltype(F) rtcGetSYCLDeviceFunctionPointer(sycl::queue& queue)
{
  sycl::buffer<cl_ulong> fptr_buf(1);
  {
    auto fptr_acc = fptr_buf.get_host_access();
    fptr_acc[0] = 0;
  }

  queue.submit([&](sycl::handler& cgh) {
      auto fptr_acc = fptr_buf.get_access<sycl::access::mode::discard_write>(cgh);
      cgh.single_task([=]() {
	  fptr_acc[0] = reinterpret_cast<cl_ulong>(F);
	});
    });
  queue.wait_and_throw();

  auto fptr_acc = fptr_buf.get_host_access();
  return (decltype(F)) fptr_acc[0];
}

#endif

RTC_NAMESPACE_END