2021-02-26 22:02:57 +00:00
|
|
|
/*
|
2022-04-25 14:54:13 +00:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2021-02-26 22:02:57 +00: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"
|
|
|
|
|
#include "shared/source/helpers/non_copyable_or_moveable.h"
|
|
|
|
|
|
2022-04-25 14:54:13 +00:00
|
|
|
#include "ocl_igc_shared/raytracing/ocl_raytracing_structures.h"
|
|
|
|
|
|
2021-02-26 22:02:57 +00:00
|
|
|
#include <cstdint>
|
|
|
|
|
namespace NEO {
|
|
|
|
|
class RayTracingHelper : public NonCopyableOrMovableClass {
|
|
|
|
|
public:
|
2021-11-16 09:23:05 +00:00
|
|
|
static constexpr uint32_t stackDssMultiplier = 2048;
|
|
|
|
|
static constexpr uint32_t hitInfoSize = 64;
|
|
|
|
|
static constexpr uint32_t bvhStackSize = 96;
|
|
|
|
|
static constexpr uint32_t memoryBackedFifoSizePerDss = 8 * KB;
|
2021-07-28 04:31:52 +00:00
|
|
|
static constexpr uint32_t maxBvhLevels = 8;
|
2021-02-26 22:02:57 +00:00
|
|
|
|
2022-10-22 04:28:30 +00:00
|
|
|
static size_t getDispatchGlobalSize(const Device &device, uint32_t maxBvhLevel, uint32_t extraBytesLocal, uint32_t extraBytesGlobal) {
|
|
|
|
|
return static_cast<size_t>(alignUp(sizeof(RTDispatchGlobals), MemoryConstants::cacheLineSize) +
|
|
|
|
|
getStackSizePerRay(maxBvhLevel, extraBytesLocal) * getNumRtStacks(device) +
|
|
|
|
|
extraBytesGlobal);
|
2021-11-16 09:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t getTotalMemoryBackedFifoSize(const Device &device) {
|
|
|
|
|
return static_cast<size_t>(getNumDss(device)) * memoryBackedFifoSizePerDss;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static size_t getMemoryBackedFifoSizeToPatch() {
|
|
|
|
|
return static_cast<size_t>(Math::log2(memoryBackedFifoSizePerDss / KB) - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static uint32_t getNumRtStacks(const Device &device) {
|
2022-08-04 23:32:29 +00:00
|
|
|
return device.getHardwareInfo().gtSystemInfo.MaxDualSubSlicesSupported * stackDssMultiplier;
|
2021-11-16 09:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static uint32_t getNumRtStacksPerDss(const Device &device) {
|
|
|
|
|
return stackDssMultiplier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static uint32_t getNumDss(const Device &device) {
|
2022-08-04 23:32:29 +00:00
|
|
|
return device.getHardwareInfo().gtSystemInfo.MaxDualSubSlicesSupported;
|
2021-11-16 09:23:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static uint32_t getStackSizePerRay(uint32_t maxBvhLevel, uint32_t extraBytesLocal) {
|
2022-07-21 18:44:54 +00:00
|
|
|
return hitInfoSize + bvhStackSize * maxBvhLevel + extraBytesLocal;
|
2021-11-16 09:23:05 +00:00
|
|
|
}
|
2021-02-26 22:02:57 +00:00
|
|
|
};
|
|
|
|
|
} // namespace NEO
|