mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
feature: Ray Tracing Acceleration Structure (RTAS) Support
Related-To: LOCI-3419 Signed-off-by: Latif, Raiyan <raiyan.latif@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
0538f0524a
commit
179abf00de
13
level_zero/core/source/rtas/CMakeLists.txt
Normal file
13
level_zero/core/source/rtas/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Copyright (C) 2023 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rtas.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/rtas.h
|
||||
)
|
||||
add_subdirectories()
|
||||
13
level_zero/core/source/rtas/linux/CMakeLists.txt
Normal file
13
level_zero/core/source/rtas/linux/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Copyright (C) 2023 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(UNIX)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_rtas_enumeration.cpp
|
||||
)
|
||||
endif()
|
||||
12
level_zero/core/source/rtas/linux/os_rtas_enumeration.cpp
Normal file
12
level_zero/core/source/rtas/linux/os_rtas_enumeration.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/rtas/rtas.h"
|
||||
|
||||
namespace L0 {
|
||||
std::string RTASBuilder::rtasLibraryName = "libze_intel_gpu_raytracing.so";
|
||||
} // namespace L0
|
||||
168
level_zero/core/source/rtas/rtas.cpp
Normal file
168
level_zero/core/source/rtas/rtas.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/rtas/rtas.h"
|
||||
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
|
||||
#include "level_zero/core/source/driver/driver_handle_imp.h"
|
||||
|
||||
namespace L0 {
|
||||
|
||||
const std::string zeRTASBuilderCreateExpImpl = "zeRTASBuilderCreateExpImpl";
|
||||
const std::string zeRTASBuilderDestroyExpImpl = "zeRTASBuilderDestroyExpImpl";
|
||||
const std::string zeRTASBuilderGetBuildPropertiesExpImpl = "zeRTASBuilderGetBuildPropertiesExpImpl";
|
||||
const std::string zeRTASBuilderBuildExpImpl = "zeRTASBuilderBuildExpImpl";
|
||||
const std::string zeDriverRTASFormatCompatibilityCheckExpImpl = "zeDriverRTASFormatCompatibilityCheckExpImpl";
|
||||
const std::string zeRTASParallelOperationCreateExpImpl = "zeRTASParallelOperationCreateExpImpl";
|
||||
const std::string zeRTASParallelOperationDestroyExpImpl = "zeRTASParallelOperationDestroyExpImpl";
|
||||
const std::string zeRTASParallelOperationGetPropertiesExpImpl = "zeRTASParallelOperationGetPropertiesExpImpl";
|
||||
const std::string zeRTASParallelOperationJoinExpImpl = "zeRTASParallelOperationJoinExpImpl";
|
||||
|
||||
pRTASBuilderCreateExpImpl builderCreateExpImpl;
|
||||
pRTASBuilderDestroyExpImpl builderDestroyExpImpl;
|
||||
pRTASBuilderGetBuildPropertiesExpImpl builderGetBuildPropertiesExpImpl;
|
||||
pRTASBuilderBuildExpImpl builderBuildExpImpl;
|
||||
pDriverRTASFormatCompatibilityCheckExpImpl formatCompatibilityCheckExpImpl;
|
||||
pRTASParallelOperationCreateExpImpl parallelOperationCreateExpImpl;
|
||||
pRTASParallelOperationDestroyExpImpl parallelOperationDestroyExpImpl;
|
||||
pRTASParallelOperationGetPropertiesExpImpl parallelOperationGetPropertiesExpImpl;
|
||||
pRTASParallelOperationJoinExpImpl parallelOperationJoinExpImpl;
|
||||
|
||||
RTASBuilder::OsLibraryLoadPtr RTASBuilder::osLibraryLoadFunction(NEO::OsLibrary::load);
|
||||
|
||||
bool RTASBuilder::loadEntryPoints(NEO::OsLibrary *libraryHandle) {
|
||||
bool ok = getSymbolAddr(libraryHandle, zeRTASBuilderCreateExpImpl, builderCreateExpImpl);
|
||||
ok = ok && getSymbolAddr(libraryHandle, zeRTASBuilderDestroyExpImpl, builderDestroyExpImpl);
|
||||
ok = ok && getSymbolAddr(libraryHandle, zeRTASBuilderGetBuildPropertiesExpImpl, builderGetBuildPropertiesExpImpl);
|
||||
ok = ok && getSymbolAddr(libraryHandle, zeRTASBuilderBuildExpImpl, builderBuildExpImpl);
|
||||
ok = ok && getSymbolAddr(libraryHandle, zeDriverRTASFormatCompatibilityCheckExpImpl, formatCompatibilityCheckExpImpl);
|
||||
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationCreateExpImpl, parallelOperationCreateExpImpl);
|
||||
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationDestroyExpImpl, parallelOperationDestroyExpImpl);
|
||||
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationGetPropertiesExpImpl, parallelOperationGetPropertiesExpImpl);
|
||||
ok = ok && getSymbolAddr(libraryHandle, zeRTASParallelOperationJoinExpImpl, parallelOperationJoinExpImpl);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
ze_result_t RTASBuilder::getProperties(const ze_rtas_builder_build_op_exp_desc_t *args,
|
||||
ze_rtas_builder_exp_properties_t *pProp) {
|
||||
return builderGetBuildPropertiesExpImpl(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,
|
||||
ze_rtas_parallel_operation_exp_handle_t hParallelOperation,
|
||||
void *pBuildUserPtr, ze_rtas_aabb_exp_t *pBounds,
|
||||
size_t *pRtasBufferSizeBytes) {
|
||||
RTASParallelOperation *parallelOperation = RTASParallelOperation::fromHandle(hParallelOperation);
|
||||
|
||||
return builderBuildExpImpl(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();
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
return formatCompatibilityCheckExpImpl(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();
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
auto pRTASBuilder = std::make_unique<RTASBuilder>();
|
||||
|
||||
result = builderCreateExpImpl(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) {
|
||||
return result;
|
||||
}
|
||||
|
||||
delete this;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::loadRTASLibrary() {
|
||||
std::lock_guard<std::mutex> lock(this->rtasLock);
|
||||
|
||||
if (this->rtasLibraryUnavailable == true) {
|
||||
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
if (this->rtasLibraryHandle == nullptr) {
|
||||
this->rtasLibraryHandle = std::unique_ptr<NEO::OsLibrary>(RTASBuilder::osLibraryLoadFunction(RTASBuilder::rtasLibraryName));
|
||||
if (this->rtasLibraryHandle == nullptr || RTASBuilder::loadEntryPoints(this->rtasLibraryHandle.get()) == false) {
|
||||
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());
|
||||
return ZE_RESULT_ERROR_DEPENDENCY_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
ze_result_t DriverHandleImp::createRTASParallelOperation(ze_rtas_parallel_operation_exp_handle_t *phParallelOperation) {
|
||||
ze_result_t result = this->loadRTASLibrary();
|
||||
if (result != ZE_RESULT_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
auto pRTASParallelOperation = std::make_unique<RTASParallelOperation>();
|
||||
|
||||
result = parallelOperationCreateExpImpl(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) {
|
||||
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 RTASParallelOperation::join() {
|
||||
return parallelOperationJoinExpImpl(this->handleImpl);
|
||||
}
|
||||
|
||||
} // namespace L0
|
||||
112
level_zero/core/source/rtas/rtas.h
Normal file
112
level_zero/core/source/rtas/rtas.h
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
struct _ze_rtas_builder_exp_handle_t {};
|
||||
struct _ze_rtas_parallel_operation_exp_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.
|
||||
*/
|
||||
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);
|
||||
|
||||
typedef ze_result_t (*pRTASBuilderDestroyExpImpl)(ze_rtas_builder_exp_handle_t hBuilder);
|
||||
|
||||
typedef ze_result_t (*pRTASBuilderGetBuildPropertiesExpImpl)(ze_rtas_builder_exp_handle_t hBuilder,
|
||||
const ze_rtas_builder_build_op_exp_desc_t *args,
|
||||
ze_rtas_builder_exp_properties_t *pProp);
|
||||
|
||||
typedef ze_result_t (*pRTASBuilderBuildExpImpl)(ze_rtas_builder_exp_handle_t hBuilder,
|
||||
const ze_rtas_builder_build_op_exp_desc_t *args,
|
||||
void *pScratchBuffer, size_t scratchBufferSizeBytes,
|
||||
void *pRtasBuffer, size_t rtasBufferSizeBytes,
|
||||
ze_rtas_parallel_operation_exp_handle_t hParallelOperation,
|
||||
void *pBuildUserPtr, ze_rtas_aabb_exp_t *pBounds,
|
||||
size_t *pRtasBufferSizeBytes);
|
||||
|
||||
typedef ze_result_t (*pDriverRTASFormatCompatibilityCheckExpImpl)(ze_driver_handle_t hDriver,
|
||||
const ze_rtas_format_exp_t accelFormat,
|
||||
const ze_rtas_format_exp_t otherAccelFormat);
|
||||
|
||||
typedef ze_result_t (*pRTASParallelOperationCreateExpImpl)(ze_driver_handle_t hDriver,
|
||||
ze_rtas_parallel_operation_exp_handle_t *phParallelOperation);
|
||||
|
||||
typedef ze_result_t (*pRTASParallelOperationDestroyExpImpl)(ze_rtas_parallel_operation_exp_handle_t hParallelOperation);
|
||||
|
||||
typedef ze_result_t (*pRTASParallelOperationGetPropertiesExpImpl)(ze_rtas_parallel_operation_exp_handle_t hParallelOperation,
|
||||
ze_rtas_parallel_operation_exp_properties_t *pProperties);
|
||||
|
||||
typedef ze_result_t (*pRTASParallelOperationJoinExpImpl)(ze_rtas_parallel_operation_exp_handle_t hParallelOperation);
|
||||
|
||||
extern pRTASBuilderCreateExpImpl builderCreateExpImpl;
|
||||
extern pRTASBuilderDestroyExpImpl builderDestroyExpImpl;
|
||||
extern pRTASBuilderGetBuildPropertiesExpImpl builderGetBuildPropertiesExpImpl;
|
||||
extern pRTASBuilderBuildExpImpl builderBuildExpImpl;
|
||||
extern pDriverRTASFormatCompatibilityCheckExpImpl formatCompatibilityCheckExpImpl;
|
||||
extern pRTASParallelOperationCreateExpImpl parallelOperationCreateExpImpl;
|
||||
extern pRTASParallelOperationDestroyExpImpl parallelOperationDestroyExpImpl;
|
||||
extern pRTASParallelOperationGetPropertiesExpImpl parallelOperationGetPropertiesExpImpl;
|
||||
extern pRTASParallelOperationJoinExpImpl parallelOperationJoinExpImpl;
|
||||
|
||||
struct RTASBuilder : _ze_rtas_builder_exp_handle_t {
|
||||
public:
|
||||
virtual ~RTASBuilder() = default;
|
||||
|
||||
ze_result_t destroy();
|
||||
ze_result_t getProperties(const ze_rtas_builder_build_op_exp_desc_t *args,
|
||||
ze_rtas_builder_exp_properties_t *pProp);
|
||||
ze_result_t build(const ze_rtas_builder_build_op_exp_desc_t *args,
|
||||
void *pScratchBuffer, size_t scratchBufferSizeBytes,
|
||||
void *pRtasBuffer, size_t rtasBufferSizeBytes,
|
||||
ze_rtas_parallel_operation_exp_handle_t hParallelOperation,
|
||||
void *pBuildUserPtr, ze_rtas_aabb_exp_t *pBounds,
|
||||
size_t *pRtasBufferSizeBytes);
|
||||
|
||||
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; }
|
||||
|
||||
using OsLibraryLoadPtr = std::add_pointer<NEO::OsLibrary *(const std::string &)>::type;
|
||||
static OsLibraryLoadPtr osLibraryLoadFunction;
|
||||
static std::string rtasLibraryName;
|
||||
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_exp_handle_t handleImpl;
|
||||
};
|
||||
|
||||
struct RTASParallelOperation : _ze_rtas_parallel_operation_exp_handle_t {
|
||||
public:
|
||||
virtual ~RTASParallelOperation() = default;
|
||||
|
||||
ze_result_t destroy();
|
||||
ze_result_t getProperties(ze_rtas_parallel_operation_exp_properties_t *pProperties);
|
||||
ze_result_t join();
|
||||
|
||||
static RTASParallelOperation *fromHandle(ze_rtas_parallel_operation_exp_handle_t handle) { return static_cast<RTASParallelOperation *>(handle); }
|
||||
inline ze_rtas_parallel_operation_exp_handle_t toHandle() { return this; }
|
||||
|
||||
ze_rtas_parallel_operation_exp_handle_t handleImpl;
|
||||
};
|
||||
|
||||
} // namespace L0
|
||||
13
level_zero/core/source/rtas/windows/CMakeLists.txt
Normal file
13
level_zero/core/source/rtas/windows/CMakeLists.txt
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Copyright (C) 2023 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(WIN32)
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_rtas_enumeration.cpp
|
||||
)
|
||||
endif()
|
||||
12
level_zero/core/source/rtas/windows/os_rtas_enumeration.cpp
Normal file
12
level_zero/core/source/rtas/windows/os_rtas_enumeration.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "level_zero/core/source/rtas/rtas.h"
|
||||
|
||||
namespace L0 {
|
||||
std::string RTASBuilder::rtasLibraryName = "ze_intel_gpu_raytracing.dll";
|
||||
} // namespace L0
|
||||
Reference in New Issue
Block a user