feature: RTAS EXT support

- Added Support for the RTAs Extension support replacing the Exp support
which will remain for backwards compatability.

Related-To: NEO-15257

Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
This commit is contained in:
Neil R. Spruit
2025-06-30 22:05:51 +00:00
committed by Compute-Runtime-Automation
parent 75d592d940
commit 1abaf40799
15 changed files with 1107 additions and 14 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,5 +8,5 @@
#include "level_zero/core/source/rtas/rtas.h"
namespace L0 {
std::string RTASBuilder::rtasLibraryName = "libze_intel_gpu_raytracing.so";
std::string rtasLibraryName = "libze_intel_gpu_raytracing.so";
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -33,6 +33,26 @@ pRTASParallelOperationCreateExpImpl parallelOperationCreateExpImpl;
pRTASParallelOperationDestroyExpImpl parallelOperationDestroyExpImpl;
pRTASParallelOperationGetPropertiesExpImpl parallelOperationGetPropertiesExpImpl;
pRTASParallelOperationJoinExpImpl parallelOperationJoinExpImpl;
// RTAS Extension function pointers
const std::string zeRTASBuilderCreateExtImpl = "zeRTASBuilderCreateExtImpl";
const std::string zeRTASBuilderDestroyExtImpl = "zeRTASBuilderDestroyExtImpl";
const std::string zeRTASBuilderGetBuildPropertiesExtImpl = "zeRTASBuilderGetBuildPropertiesExtImpl";
const std::string zeRTASBuilderBuildExtImpl = "zeRTASBuilderBuildExtImpl";
const std::string zeDriverRTASFormatCompatibilityCheckExtImpl = "zeDriverRTASFormatCompatibilityCheckExtImpl";
const std::string zeRTASParallelOperationCreateExtImpl = "zeRTASParallelOperationCreateExtImpl";
const std::string zeRTASParallelOperationDestroyExtImpl = "zeRTASParallelOperationDestroyExtImpl";
const std::string zeRTASParallelOperationGetPropertiesExtImpl = "zeRTASParallelOperationGetPropertiesExtImpl";
const std::string zeRTASParallelOperationJoinExtImpl = "zeRTASParallelOperationJoinExtImpl";
pRTASBuilderCreateExtImpl builderCreateExtImpl;
pRTASBuilderDestroyExtImpl builderDestroyExtImpl;
pDriverRTASFormatCompatibilityCheckExtImpl formatCompatibilityCheckExtImpl;
pRTASBuilderGetBuildPropertiesExtImpl builderGetBuildPropertiesExtImpl;
pRTASBuilderBuildExtImpl builderBuildExtImpl;
pRTASParallelOperationCreateExtImpl parallelOperationCreateExtImpl;
pRTASParallelOperationDestroyExtImpl parallelOperationDestroyExtImpl;
pRTASParallelOperationGetPropertiesExtImpl parallelOperationGetPropertiesExtImpl;
pRTASParallelOperationJoinExtImpl parallelOperationJoinExtImpl;
bool RTASBuilder::loadEntryPoints(NEO::OsLibrary *libraryHandle) {
bool ok = getSymbolAddr(libraryHandle, zeRTASBuilderCreateExpImpl, builderCreateExpImpl);
@@ -44,7 +64,19 @@ bool RTASBuilder::loadEntryPoints(NEO::OsLibrary *libraryHandle) {
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationDestroyExpImpl, parallelOperationDestroyExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationGetPropertiesExpImpl, parallelOperationGetPropertiesExpImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationJoinExpImpl, parallelOperationJoinExpImpl);
return ok;
}
bool RTASBuilderExt::loadEntryPoints(NEO::OsLibrary *libraryHandle) {
bool ok = getSymbolAddr(libraryHandle, zeRTASBuilderCreateExtImpl, builderCreateExtImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASBuilderDestroyExtImpl, builderDestroyExtImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASBuilderGetBuildPropertiesExtImpl, builderGetBuildPropertiesExtImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASBuilderBuildExtImpl, builderBuildExtImpl);
ok = ok && getSymbolAddr(libraryHandle, zeDriverRTASFormatCompatibilityCheckExtImpl, formatCompatibilityCheckExtImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationCreateExtImpl, parallelOperationCreateExtImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationDestroyExtImpl, parallelOperationDestroyExtImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationGetPropertiesExtImpl, parallelOperationGetPropertiesExtImpl);
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationJoinExtImpl, parallelOperationJoinExtImpl);
return ok;
}
@@ -53,6 +85,11 @@ ze_result_t RTASBuilder::getProperties(const ze_rtas_builder_build_op_exp_desc_t
return builderGetBuildPropertiesExpImpl(this->handleImpl, args, pProp);
}
ze_result_t RTASBuilderExt::getProperties(const ze_rtas_builder_build_op_ext_desc_t *args,
ze_rtas_builder_ext_properties_t *pProp) {
return builderGetBuildPropertiesExtImpl(this->handleImpl, args, pProp);
}
ze_result_t RTASBuilder::build(const ze_rtas_builder_build_op_exp_desc_t *args,
void *pScratchBuffer, size_t scratchBufferSizeBytes,
void *pRtasBuffer, size_t rtasBufferSizeBytes,
@@ -70,6 +107,23 @@ ze_result_t RTASBuilder::build(const ze_rtas_builder_build_op_exp_desc_t *args,
pRtasBufferSizeBytes);
}
ze_result_t RTASBuilderExt::build(const ze_rtas_builder_build_op_ext_desc_t *args,
void *pScratchBuffer, size_t scratchBufferSizeBytes,
void *pRtasBuffer, size_t rtasBufferSizeBytes,
ze_rtas_parallel_operation_ext_handle_t hParallelOperation,
void *pBuildUserPtr, ze_rtas_aabb_ext_t *pBounds,
size_t *pRtasBufferSizeBytes) {
RTASParallelOperationExt *parallelOperation = RTASParallelOperationExt::fromHandle(hParallelOperation);
return builderBuildExtImpl(this->handleImpl,
args,
pScratchBuffer, scratchBufferSizeBytes,
pRtasBuffer, rtasBufferSizeBytes,
parallelOperation->handleImpl,
pBuildUserPtr, pBounds,
pRtasBufferSizeBytes);
}
ze_result_t DriverHandleImp::formatRTASCompatibilityCheck(ze_rtas_format_exp_t rtasFormatA,
ze_rtas_format_exp_t rtasFormatB) {
ze_result_t result = this->loadRTASLibrary();
@@ -80,6 +134,16 @@ ze_result_t DriverHandleImp::formatRTASCompatibilityCheck(ze_rtas_format_exp_t r
return formatCompatibilityCheckExpImpl(this->toHandle(), rtasFormatA, rtasFormatB);
}
ze_result_t DriverHandleImp::formatRTASCompatibilityCheckExt(ze_rtas_format_ext_t rtasFormatA,
ze_rtas_format_ext_t rtasFormatB) {
ze_result_t result = this->loadRTASLibrary();
if (result != ZE_RESULT_SUCCESS) {
return result;
}
return formatCompatibilityCheckExtImpl(this->toHandle(), rtasFormatA, rtasFormatB);
}
ze_result_t DriverHandleImp::createRTASBuilder(const ze_rtas_builder_exp_desc_t *desc,
ze_rtas_builder_exp_handle_t *phBuilder) {
ze_result_t result = this->loadRTASLibrary();
@@ -98,6 +162,24 @@ ze_result_t DriverHandleImp::createRTASBuilder(const ze_rtas_builder_exp_desc_t
return ZE_RESULT_SUCCESS;
}
ze_result_t DriverHandleImp::createRTASBuilderExt(const ze_rtas_builder_ext_desc_t *desc,
ze_rtas_builder_ext_handle_t *phBuilder) {
ze_result_t result = this->loadRTASLibrary();
if (result != ZE_RESULT_SUCCESS) {
return result;
}
auto pRTASBuilder = std::make_unique<RTASBuilderExt>();
result = builderCreateExtImpl(this->toHandle(), desc, &pRTASBuilder->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
*phBuilder = pRTASBuilder.release();
return ZE_RESULT_SUCCESS;
}
ze_result_t RTASBuilder::destroy() {
ze_result_t result = builderDestroyExpImpl(this->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
@@ -108,6 +190,16 @@ ze_result_t RTASBuilder::destroy() {
return ZE_RESULT_SUCCESS;
}
ze_result_t RTASBuilderExt::destroy() {
ze_result_t result = builderDestroyExtImpl(this->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
delete this;
return ZE_RESULT_SUCCESS;
}
ze_result_t DriverHandleImp::loadRTASLibrary() {
std::lock_guard<std::mutex> lock(this->rtasLock);
@@ -116,11 +208,17 @@ ze_result_t DriverHandleImp::loadRTASLibrary() {
}
if (this->rtasLibraryHandle == nullptr) {
this->rtasLibraryHandle = std::unique_ptr<NEO::OsLibrary>(NEO::OsLibrary::loadFunc(RTASBuilder::rtasLibraryName));
if (this->rtasLibraryHandle == nullptr || RTASBuilder::loadEntryPoints(this->rtasLibraryHandle.get()) == false) {
this->rtasLibraryHandle = std::unique_ptr<NEO::OsLibrary>(NEO::OsLibrary::loadFunc(L0::rtasLibraryName));
bool rtasExpAvailable = false;
bool rtasExtAvailable = false;
if (this->rtasLibraryHandle != nullptr) {
rtasExpAvailable = RTASBuilder::loadEntryPoints(this->rtasLibraryHandle.get());
rtasExtAvailable = RTASBuilderExt::loadEntryPoints(this->rtasLibraryHandle.get());
}
if (this->rtasLibraryHandle == nullptr || (!rtasExpAvailable && !rtasExtAvailable)) {
this->rtasLibraryUnavailable = true;
PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Failed to load Ray Tracing Support Library %s\n", RTASBuilder::rtasLibraryName.c_str());
PRINT_DEBUG_STRING(NEO::debugManager.flags.PrintDebugMessages.get(), stderr, "Failed to load Ray Tracing Support Library %s\n", L0::rtasLibraryName.c_str());
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
}
}
@@ -145,6 +243,23 @@ ze_result_t DriverHandleImp::createRTASParallelOperation(ze_rtas_parallel_operat
return ZE_RESULT_SUCCESS;
}
ze_result_t DriverHandleImp::createRTASParallelOperationExt(ze_rtas_parallel_operation_ext_handle_t *phParallelOperation) {
ze_result_t result = this->loadRTASLibrary();
if (result != ZE_RESULT_SUCCESS) {
return result;
}
auto pRTASParallelOperation = std::make_unique<RTASParallelOperationExt>();
result = parallelOperationCreateExtImpl(this->toHandle(), &pRTASParallelOperation->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
*phParallelOperation = pRTASParallelOperation.release();
return ZE_RESULT_SUCCESS;
}
ze_result_t RTASParallelOperation::destroy() {
ze_result_t result = parallelOperationDestroyExpImpl(this->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
@@ -155,12 +270,30 @@ ze_result_t RTASParallelOperation::destroy() {
return ZE_RESULT_SUCCESS;
}
ze_result_t RTASParallelOperationExt::destroy() {
ze_result_t result = parallelOperationDestroyExtImpl(this->handleImpl);
if (result != ZE_RESULT_SUCCESS) {
return result;
}
delete this;
return ZE_RESULT_SUCCESS;
}
ze_result_t RTASParallelOperation::getProperties(ze_rtas_parallel_operation_exp_properties_t *pProperties) {
return parallelOperationGetPropertiesExpImpl(this->handleImpl, pProperties);
}
ze_result_t RTASParallelOperationExt::getProperties(ze_rtas_parallel_operation_ext_properties_t *pProperties) {
return parallelOperationGetPropertiesExtImpl(this->handleImpl, pProperties);
}
ze_result_t RTASParallelOperation::join() {
return parallelOperationJoinExpImpl(this->handleImpl);
}
ze_result_t RTASParallelOperationExt::join() {
return parallelOperationJoinExtImpl(this->handleImpl);
}
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023-2024 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -15,12 +15,16 @@
struct _ze_rtas_builder_exp_handle_t {};
struct _ze_rtas_parallel_operation_exp_handle_t {};
struct _ze_rtas_builder_ext_handle_t {};
struct _ze_rtas_parallel_operation_ext_handle_t {};
namespace L0 {
/*
* Note: RTAS Library using same headers as Level Zero, but using function
* pointers to access these symbols in the external Library.
*/
// Exp Functions
typedef ze_result_t (*pRTASBuilderCreateExpImpl)(ze_driver_handle_t hDriver,
const ze_rtas_builder_exp_desc_t *pDescriptor,
ze_rtas_builder_exp_handle_t *phBuilder);
@@ -53,6 +57,39 @@ typedef ze_result_t (*pRTASParallelOperationGetPropertiesExpImpl)(ze_rtas_parall
typedef ze_result_t (*pRTASParallelOperationJoinExpImpl)(ze_rtas_parallel_operation_exp_handle_t hParallelOperation);
// Ext Functions
typedef ze_result_t (*pRTASBuilderCreateExtImpl)(ze_driver_handle_t hDriver,
const ze_rtas_builder_ext_desc_t *pDescriptor,
ze_rtas_builder_ext_handle_t *phBuilder);
typedef ze_result_t (*pRTASBuilderDestroyExtImpl)(ze_rtas_builder_ext_handle_t hBuilder);
typedef ze_result_t (*pRTASBuilderGetBuildPropertiesExtImpl)(ze_rtas_builder_ext_handle_t hBuilder,
const ze_rtas_builder_build_op_ext_desc_t *args,
ze_rtas_builder_ext_properties_t *pProp);
typedef ze_result_t (*pRTASBuilderBuildExtImpl)(ze_rtas_builder_ext_handle_t hBuilder,
const ze_rtas_builder_build_op_ext_desc_t *args,
void *pScratchBuffer, size_t scratchBufferSizeBytes,
void *pRtasBuffer, size_t rtasBufferSizeBytes,
ze_rtas_parallel_operation_ext_handle_t hParallelOperation,
void *pBuildUserPtr, ze_rtas_aabb_ext_t *pBounds,
size_t *pRtasBufferSizeBytes);
typedef ze_result_t (*pDriverRTASFormatCompatibilityCheckExtImpl)(ze_driver_handle_t hDriver,
const ze_rtas_format_ext_t accelFormat,
const ze_rtas_format_ext_t otherAccelFormat);
typedef ze_result_t (*pRTASParallelOperationCreateExtImpl)(ze_driver_handle_t hDriver,
ze_rtas_parallel_operation_ext_handle_t *phParallelOperation);
typedef ze_result_t (*pRTASParallelOperationDestroyExtImpl)(ze_rtas_parallel_operation_ext_handle_t hParallelOperation);
typedef ze_result_t (*pRTASParallelOperationGetPropertiesExtImpl)(ze_rtas_parallel_operation_ext_handle_t hParallelOperation,
ze_rtas_parallel_operation_ext_properties_t *pProperties);
typedef ze_result_t (*pRTASParallelOperationJoinExtImpl)(ze_rtas_parallel_operation_ext_handle_t hParallelOperation);
extern pRTASBuilderCreateExpImpl builderCreateExpImpl;
extern pRTASBuilderDestroyExpImpl builderDestroyExpImpl;
extern pRTASBuilderGetBuildPropertiesExpImpl builderGetBuildPropertiesExpImpl;
@@ -62,6 +99,17 @@ extern pRTASParallelOperationCreateExpImpl parallelOperationCreateExpImpl;
extern pRTASParallelOperationDestroyExpImpl parallelOperationDestroyExpImpl;
extern pRTASParallelOperationGetPropertiesExpImpl parallelOperationGetPropertiesExpImpl;
extern pRTASParallelOperationJoinExpImpl parallelOperationJoinExpImpl;
// RTAS Extension function pointers
extern pRTASBuilderCreateExtImpl builderCreateExtImpl;
extern pRTASBuilderDestroyExtImpl builderDestroyExtImpl;
extern pRTASBuilderGetBuildPropertiesExtImpl builderGetBuildPropertiesExtImpl;
extern pRTASBuilderBuildExtImpl builderBuildExtImpl;
extern pDriverRTASFormatCompatibilityCheckExtImpl formatCompatibilityCheckExtImpl;
extern pRTASParallelOperationCreateExtImpl parallelOperationCreateExtImpl;
extern pRTASParallelOperationDestroyExtImpl parallelOperationDestroyExtImpl;
extern pRTASParallelOperationGetPropertiesExtImpl parallelOperationGetPropertiesExtImpl;
extern pRTASParallelOperationJoinExtImpl parallelOperationJoinExtImpl;
extern std::string rtasLibraryName;
struct RTASBuilder : _ze_rtas_builder_exp_handle_t {
public:
@@ -80,7 +128,6 @@ struct RTASBuilder : _ze_rtas_builder_exp_handle_t {
static RTASBuilder *fromHandle(ze_rtas_builder_exp_handle_t handle) { return static_cast<RTASBuilder *>(handle); }
inline ze_rtas_builder_exp_handle_t toHandle() { return this; }
static std::string rtasLibraryName;
static bool loadEntryPoints(NEO::OsLibrary *libraryHandle);
template <class T>
@@ -107,4 +154,47 @@ struct RTASParallelOperation : _ze_rtas_parallel_operation_exp_handle_t {
ze_rtas_parallel_operation_exp_handle_t handleImpl;
};
struct RTASBuilderExt : _ze_rtas_builder_ext_handle_t {
public:
virtual ~RTASBuilderExt() = default;
ze_result_t destroy();
ze_result_t getProperties(const ze_rtas_builder_build_op_ext_desc_t *args,
ze_rtas_builder_ext_properties_t *pProp);
ze_result_t build(const ze_rtas_builder_build_op_ext_desc_t *args,
void *pScratchBuffer, size_t scratchBufferSizeBytes,
void *pRtasBuffer, size_t rtasBufferSizeBytes,
ze_rtas_parallel_operation_ext_handle_t hParallelOperation,
void *pBuildUserPtr, ze_rtas_aabb_ext_t *pBounds,
size_t *pRtasBufferSizeBytes);
static RTASBuilderExt *fromHandle(ze_rtas_builder_ext_handle_t handle) { return static_cast<RTASBuilderExt *>(handle); }
inline ze_rtas_builder_ext_handle_t toHandle() { return this; }
static bool loadEntryPoints(NEO::OsLibrary *libraryHandle);
template <class T>
static bool getSymbolAddr(NEO::OsLibrary *libraryHandle, const std::string name, T &proc) {
void *addr = libraryHandle->getProcAddress(name);
proc = reinterpret_cast<T>(addr);
return nullptr != proc;
}
ze_rtas_builder_ext_handle_t handleImpl;
};
struct RTASParallelOperationExt : _ze_rtas_parallel_operation_ext_handle_t {
public:
virtual ~RTASParallelOperationExt() = default;
ze_result_t destroy();
ze_result_t getProperties(ze_rtas_parallel_operation_ext_properties_t *pProperties);
ze_result_t join();
static RTASParallelOperationExt *fromHandle(ze_rtas_parallel_operation_ext_handle_t handle) { return static_cast<RTASParallelOperationExt *>(handle); }
inline ze_rtas_parallel_operation_ext_handle_t toHandle() { return this; }
ze_rtas_parallel_operation_ext_handle_t handleImpl;
};
} // namespace L0

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2023-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -8,5 +8,5 @@
#include "level_zero/core/source/rtas/rtas.h"
namespace L0 {
std::string RTASBuilder::rtasLibraryName = "ze_intel_gpu_raytracing.dll";
std::string rtasLibraryName = "ze_intel_gpu_raytracing.dll";
} // namespace L0