2021-02-27 06:02:57 +08:00
|
|
|
/*
|
2024-10-16 20:05:13 +08:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2021-02-27 06:02:57 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "shared/source/device/device.h"
|
|
|
|
#include "shared/source/helpers/aligned_memory.h"
|
|
|
|
#include "shared/source/helpers/basic_math.h"
|
2023-03-10 09:20:44 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2023-02-06 17:05:43 +08:00
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2021-02-27 06:02:57 +08:00
|
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
2024-11-18 21:24:30 +08:00
|
|
|
#include "shared/source/release_helper/release_helper.h"
|
2021-02-27 06:02:57 +08:00
|
|
|
|
2022-04-25 22:54:13 +08:00
|
|
|
#include "ocl_igc_shared/raytracing/ocl_raytracing_structures.h"
|
|
|
|
|
2021-02-27 06:02:57 +08:00
|
|
|
#include <cstdint>
|
2024-11-18 21:24:30 +08:00
|
|
|
|
2021-02-27 06:02:57 +08:00
|
|
|
namespace NEO {
|
|
|
|
class RayTracingHelper : public NonCopyableOrMovableClass {
|
|
|
|
public:
|
2021-11-16 17:23:05 +08:00
|
|
|
static constexpr uint32_t hitInfoSize = 64;
|
|
|
|
static constexpr uint32_t bvhStackSize = 96;
|
2023-12-04 23:55:01 +08:00
|
|
|
static constexpr uint32_t memoryBackedFifoSizePerDss = 8 * MemoryConstants::kiloByte;
|
2021-07-28 12:31:52 +08:00
|
|
|
static constexpr uint32_t maxBvhLevels = 8;
|
2021-02-27 06:02:57 +08:00
|
|
|
|
2024-11-18 21:24:30 +08:00
|
|
|
static constexpr uint32_t maxSizeOfRtStacksPerDss = 4096;
|
|
|
|
static constexpr uint32_t fixedSizeOfRtStacksPerDss = 2048;
|
|
|
|
|
2022-11-04 10:35:20 +08:00
|
|
|
static size_t getDispatchGlobalSize() {
|
|
|
|
return static_cast<size_t>(alignUp(sizeof(RTDispatchGlobals), MemoryConstants::cacheLineSize));
|
|
|
|
}
|
|
|
|
|
|
|
|
static size_t getRTStackSizePerTile(const Device &device, uint32_t tiles, uint32_t maxBvhLevel, uint32_t extraBytesLocal, uint32_t extraBytesGlobal) {
|
2024-11-18 21:24:30 +08:00
|
|
|
return static_cast<size_t>(alignUp(getStackSizePerRay(maxBvhLevel, extraBytesLocal) * (getNumRtStacks(device)) + extraBytesGlobal, MemoryConstants::cacheLineSize));
|
2021-11-16 17:23:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static size_t getTotalMemoryBackedFifoSize(const Device &device) {
|
2023-03-10 09:20:44 +08:00
|
|
|
return static_cast<size_t>(NEO::GfxCoreHelper::getHighestEnabledDualSubSlice(device.getHardwareInfo())) * memoryBackedFifoSizePerDss;
|
2021-11-16 17:23:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static size_t getMemoryBackedFifoSizeToPatch() {
|
2023-12-04 23:55:01 +08:00
|
|
|
return static_cast<size_t>(Math::log2(memoryBackedFifoSizePerDss / MemoryConstants::kiloByte) - 1);
|
2021-11-16 17:23:05 +08:00
|
|
|
}
|
|
|
|
|
2024-11-18 21:24:30 +08:00
|
|
|
static uint32_t getNumRtStacks(const Device &device) {
|
|
|
|
return NEO::GfxCoreHelper::getHighestEnabledDualSubSlice(device.getHardwareInfo()) * getNumRtStacksPerDss(device);
|
2021-11-16 17:23:05 +08:00
|
|
|
}
|
|
|
|
|
2024-11-18 21:24:30 +08:00
|
|
|
static uint32_t getNumRtStacksPerDss(const Device &device) {
|
|
|
|
auto releaseHelper = device.getReleaseHelper();
|
|
|
|
|
|
|
|
if (releaseHelper == nullptr || releaseHelper->isNumRtStacksPerDssFixedValue()) {
|
|
|
|
return fixedSizeOfRtStacksPerDss;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &hwInfo = device.getHardwareInfo();
|
|
|
|
UNRECOVERABLE_IF(hwInfo.gtSystemInfo.EUCount == 0)
|
|
|
|
|
|
|
|
uint32_t maxNumEUsPerDSS = hwInfo.gtSystemInfo.MaxEuPerSubSlice;
|
|
|
|
uint32_t maxNumThreadsPerEU = hwInfo.gtSystemInfo.ThreadCount / hwInfo.gtSystemInfo.EUCount;
|
|
|
|
uint32_t maxSIMTThreadsPerThread = CommonConstants::maximalSimdSize;
|
|
|
|
|
|
|
|
return std::min(maxSizeOfRtStacksPerDss, maxNumEUsPerDSS * maxNumThreadsPerEU * maxSIMTThreadsPerThread);
|
2021-11-16 17:23:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t getStackSizePerRay(uint32_t maxBvhLevel, uint32_t extraBytesLocal) {
|
2022-07-22 02:44:54 +08:00
|
|
|
return hitInfoSize + bvhStackSize * maxBvhLevel + extraBytesLocal;
|
2021-11-16 17:23:05 +08:00
|
|
|
}
|
2021-02-27 06:02:57 +08:00
|
|
|
};
|
|
|
|
} // namespace NEO
|