Add RTDispatchGlobals allocation for ray tracing

If a kernel has ray tracing calls, we allocate and initialize
per-device RTDispatchGlobals if needed, and hand off pointer to
the same into a running kernel via an implicit parameter.

Related-To: NEO-5384
Signed-off-by: Jim Snow <jim.m.snow@intel.com>
This commit is contained in:
Jim Snow
2021-07-28 04:31:52 +00:00
committed by Compute-Runtime-Automation
parent 7d5924cd98
commit 2dfb7df63b
17 changed files with 213 additions and 18 deletions

View File

@@ -5,6 +5,8 @@
*
*/
#include "shared/source/device/device.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_device.h"
@@ -14,7 +16,7 @@
using namespace NEO;
TEST(DeviceTest, whenBlitterOperationsSupportIsDisabledThenNoInternalCopyEngineIsReturned) {
TEST(DeviceBlitterTest, whenBlitterOperationsSupportIsDisabledThenNoInternalCopyEngineIsReturned) {
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
defaultHwInfo->capabilityTable.blitterOperationsSupported = false;
@@ -22,7 +24,7 @@ TEST(DeviceTest, whenBlitterOperationsSupportIsDisabledThenNoInternalCopyEngineI
EXPECT_EQ(nullptr, factory.rootDevices[0]->getInternalCopyEngine());
}
TEST(DeviceTest, givenBlitterOperationsDisabledWhenCreatingBlitterEngineThenAbort) {
TEST(DeviceBlitterTest, givenBlitterOperationsDisabledWhenCreatingBlitterEngineThenAbort) {
VariableBackup<HardwareInfo> backupHwInfo(defaultHwInfo.get());
defaultHwInfo->capabilityTable.blitterOperationsSupported = false;
@@ -32,3 +34,48 @@ TEST(DeviceTest, givenBlitterOperationsDisabledWhenCreatingBlitterEngineThenAbor
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::Internal}), std::runtime_error);
EXPECT_THROW(factory.rootDevices[0]->createEngine(0, {aub_stream::EngineType::ENGINE_BCS, EngineUsage::LowPriority}), std::runtime_error);
}
using DeviceTest = Test<DeviceFixture>;
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledAndRtBackedBufferIsNullptrThenMemoryBackedBufferIsCreated) {
EXPECT_EQ(nullptr, pDevice->getRTMemoryBackedBuffer());
EXPECT_EQ(false, pDevice->rayTracingIsInitialized());
pDevice->initializeRayTracing(0);
EXPECT_NE(nullptr, pDevice->getRTMemoryBackedBuffer());
EXPECT_EQ(true, pDevice->rayTracingIsInitialized());
pDevice->initializeRayTracing(0);
EXPECT_NE(nullptr, pDevice->getRTMemoryBackedBuffer());
EXPECT_EQ(true, pDevice->rayTracingIsInitialized());
}
TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledWithUnsupportedBVHLevelsThenNullptrIsReturned) {
pDevice->initializeRayTracing(5);
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(100));
}
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledWithMockAllocatorThenRTDispatchGlobalsIsAllocated) {
pDevice->setRTDispatchGlobalsForceAllocation();
pDevice->initializeRayTracing(5);
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(3));
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(5));
}
TEST_F(DeviceTest, whenInitializeRayTracingIsCalledMultipleTimesWithMockAllocatorThenInitializeRayTracingIsIdempotent) {
pDevice->setRTDispatchGlobalsForceAllocation();
pDevice->initializeRayTracing(5);
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(5));
pDevice->initializeRayTracing(5);
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(5));
}
TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledBeforeInitializationThenNullPtrIsReturned) {
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(1));
}
TEST_F(DeviceTest, whenGetRTDispatchGlobalsIsCalledWithZeroSizeAndMockAllocatorThenDispatchGlobalsIsReturned) {
pDevice->setRTDispatchGlobalsForceAllocation();
EXPECT_EQ(nullptr, pDevice->getRTDispatchGlobals(0));
pDevice->initializeRayTracing(5);
EXPECT_NE(nullptr, pDevice->getRTDispatchGlobals(0));
}

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2020 Intel Corporation
# Copyright (C) 2020-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -11,3 +11,5 @@ target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/kernel_descriptor_from_patchtokens_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_descriptor_tests.cpp
)
add_subdirectories()