mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
This change adds 32 more bit to store kernel features. While for a short term it might be possible to make a space for one or two extra bits, it seems going 64bit is inevitable. Expanding the field to 64bit might introduce some slowdown due to less optimal cache, but so is consolidation of existing flags could also lead to performance drop in certain configurations. The main tricky part of the change is Metal where function constants are used to store kernel_features, and 64bit constants are only available on macOS 12. There is a runtime check for it. On older macOS versions the flags are stored as a pair of 32bit values. It is slower, but there are unlikely to be many Cycles users on macOS 11. Ref #159470 Pull Request: https://projects.blender.org/blender/blender/pulls/162737
69 lines
2.6 KiB
C++
69 lines
2.6 KiB
C++
/* SPDX-FileCopyrightText: 2021-2022 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#pragma once
|
|
|
|
#ifdef WITH_ONEAPI
|
|
|
|
# include <stddef.h>
|
|
|
|
# include <cstdint>
|
|
|
|
/* NOTE(@nsirgien): Should match underlying type in the declaration inside "kernel/types.h"
|
|
* TODO: use kernel/types.h directly. */
|
|
enum DeviceKernel : int;
|
|
|
|
# ifndef CYCLES_KERNEL_ONEAPI_EXPORT
|
|
# ifdef _WIN32
|
|
# if defined(ONEAPI_EXPORT)
|
|
# define CYCLES_KERNEL_ONEAPI_EXPORT extern __declspec(dllexport)
|
|
# else
|
|
# define CYCLES_KERNEL_ONEAPI_EXPORT extern __declspec(dllimport)
|
|
# endif
|
|
# else
|
|
# define CYCLES_KERNEL_ONEAPI_EXPORT extern __attribute__((visibility("default")))
|
|
# endif
|
|
# endif
|
|
|
|
class SyclQueue;
|
|
class SyclDevice;
|
|
|
|
typedef void (*OneAPIErrorCallback)(const char *error, void *user_ptr);
|
|
|
|
struct KernelContext {
|
|
/* Queue, associated with selected device */
|
|
SyclQueue *queue = nullptr;
|
|
/* Pointer to USM device memory with all global/constant allocation on this device */
|
|
void *kernel_globals = nullptr;
|
|
/* We needs this additional data for some kernels. */
|
|
int scene_max_shaders = 0;
|
|
};
|
|
|
|
/* Use extern C linking so that the symbols can be easily load from the dynamic library at runtime.
|
|
*/
|
|
# ifdef __cplusplus
|
|
extern "C" {
|
|
# endif
|
|
|
|
CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_run_test_kernel(SyclQueue *queue_);
|
|
CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_zero_memory_on_device(SyclQueue *queue_,
|
|
void *device_pointer,
|
|
size_t num_bytes);
|
|
CYCLES_KERNEL_ONEAPI_EXPORT void oneapi_set_error_cb(OneAPIErrorCallback cb, void *user_ptr);
|
|
CYCLES_KERNEL_ONEAPI_EXPORT size_t oneapi_suggested_gpu_kernel_size(const DeviceKernel kernel);
|
|
CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_enqueue_kernel(KernelContext *context,
|
|
const int kernel,
|
|
const size_t global_size,
|
|
const size_t local_size,
|
|
uint64_t kernel_features,
|
|
bool use_hardware_raytracing,
|
|
void **args);
|
|
CYCLES_KERNEL_ONEAPI_EXPORT bool oneapi_load_kernels(SyclQueue *queue,
|
|
uint64_t kernel_features,
|
|
bool use_hardware_raytracing);
|
|
# ifdef __cplusplus
|
|
}
|
|
|
|
# endif
|
|
#endif /* WITH_ONEAPI */
|