mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 14:02:58 +08:00
feature: add ZE_experimental_bindless_image extension
- add definitions and functions - Level Zero spec commit: 49c972463796e614597b028bd344e1b2f64a63b7 Related-To: NEO-10352 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
ff604bda1b
commit
22802d8680
@@ -12,6 +12,7 @@
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/execution_environment/root_device_environment.h"
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/source/helpers/hw_info.h"
|
||||
#include "shared/source/helpers/string.h"
|
||||
@@ -138,15 +139,24 @@ ze_result_t DriverHandleImp::getExtensionFunctionAddress(const char *pFuncName,
|
||||
|
||||
ze_result_t DriverHandleImp::getExtensionProperties(uint32_t *pCount,
|
||||
ze_driver_extension_properties_t *pExtensionProperties) {
|
||||
|
||||
std::vector<std::pair<std::string, uint32_t>> additionalExtensions;
|
||||
|
||||
if (NEO::ApiSpecificConfig::getGlobalBindlessHeapConfiguration()) {
|
||||
additionalExtensions.push_back({ZE_BINDLESS_IMAGE_EXP_NAME, ZE_BINDLESS_IMAGE_EXP_VERSION_CURRENT});
|
||||
}
|
||||
|
||||
auto extensionCount = static_cast<uint32_t>(this->extensionsSupported.size() + additionalExtensions.size());
|
||||
|
||||
if (nullptr == pExtensionProperties) {
|
||||
*pCount = static_cast<uint32_t>(this->extensionsSupported.size());
|
||||
*pCount = extensionCount;
|
||||
return ZE_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
*pCount = std::min(static_cast<uint32_t>(this->extensionsSupported.size()), *pCount);
|
||||
*pCount = std::min(extensionCount, *pCount);
|
||||
|
||||
for (uint32_t i = 0; i < *pCount; i++) {
|
||||
auto extension = this->extensionsSupported[i];
|
||||
auto extension = (i < this->extensionsSupported.size()) ? this->extensionsSupported[i] : additionalExtensions[i - this->extensionsSupported.size()];
|
||||
strncpy_s(pExtensionProperties[i].name, ZE_MAX_EXTENSION_NAME,
|
||||
extension.first.c_str(), extension.first.length());
|
||||
pExtensionProperties[i].version = extension.second;
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "level_zero/core/source/driver/extension_function_address.h"
|
||||
|
||||
#include "level_zero/api/driver_experimental/public/zex_api.h"
|
||||
#include "level_zero/api/extensions/public/ze_exp_ext.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@@ -36,6 +37,9 @@ void *ExtensionFunctionAddressHelper::getExtensionFunctionAddress(std::string fu
|
||||
|
||||
RETURN_FUNC_PTR_IF_EXIST(zexCounterBasedEventCreate);
|
||||
RETURN_FUNC_PTR_IF_EXIST(zexEventGetDeviceAddress);
|
||||
|
||||
RETURN_FUNC_PTR_IF_EXIST(zeMemGetPitchFor2dImage);
|
||||
RETURN_FUNC_PTR_IF_EXIST(zeImageGetDeviceOffsetExp);
|
||||
#undef RETURN_FUNC_PTR_IF_EXIST
|
||||
|
||||
return ExtensionFunctionAddressHelper::getAdditionalExtensionFunctionAddress(functionName);
|
||||
|
||||
@@ -5252,5 +5252,10 @@ TEST(ExtensionLookupTest, givenLookupMapWhenAskingForZexCommandListAppendWaitOnM
|
||||
EXPECT_NE(nullptr, ExtensionFunctionAddressHelper::getExtensionFunctionAddress("zexCommandListAppendWaitOnMemory64"));
|
||||
}
|
||||
|
||||
TEST(ExtensionLookupTest, givenLookupMapWhenAskingForBindlessImageExtensionFunctionsThenValidPointersReturned) {
|
||||
EXPECT_NE(nullptr, ExtensionFunctionAddressHelper::getExtensionFunctionAddress("zeMemGetPitchFor2dImage"));
|
||||
EXPECT_NE(nullptr, ExtensionFunctionAddressHelper::getExtensionFunctionAddress("zeImageGetDeviceOffsetExp"));
|
||||
}
|
||||
|
||||
} // namespace ult
|
||||
} // namespace L0
|
||||
|
||||
@@ -129,6 +129,31 @@ TEST_F(DriverVersionTest, givenCallToGetExtensionPropertiesThenSupportedExtensio
|
||||
delete[] extensionProperties;
|
||||
}
|
||||
|
||||
TEST_F(DriverVersionTest, givenExternalAllocatorWhenCallingGetExtensionPropertiesThenBindlessImageExtensionIsReturned) {
|
||||
DebugManagerStateRestore restorer;
|
||||
NEO::debugManager.flags.UseExternalAllocatorForSshAndDsh.set(1);
|
||||
|
||||
uint32_t count = 0;
|
||||
ze_result_t res = driverHandle->getExtensionProperties(&count, nullptr);
|
||||
EXPECT_GT(count, static_cast<uint32_t>(driverHandle->extensionsSupported.size()));
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
ze_driver_extension_properties_t *extensionProperties = new ze_driver_extension_properties_t[count];
|
||||
res = driverHandle->getExtensionProperties(&count, extensionProperties);
|
||||
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
|
||||
|
||||
bool extensionFound = false;
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
auto extension = extensionProperties[i];
|
||||
if (strcmp(extension.name, ZE_BINDLESS_IMAGE_EXP_NAME) == 0) {
|
||||
extensionFound = true;
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(extensionFound);
|
||||
|
||||
delete[] extensionProperties;
|
||||
}
|
||||
|
||||
TEST_F(DriverVersionTest, WhenGettingDriverVersionThenExpectedDriverVersionIsReturned) {
|
||||
ze_driver_properties_t properties;
|
||||
ze_result_t res = driverHandle->getProperties(&properties);
|
||||
|
||||
Reference in New Issue
Block a user