2018-11-22 22:16:20 +08:00
|
|
|
/*
|
2022-11-22 21:53:59 +08:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2018-11-22 22:16:20 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-12-07 23:38:12 +08:00
|
|
|
#include "shared/source/helpers/bindless_heaps_helper.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/indirect_heap/indirect_heap.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2018-11-22 22:16:20 +08:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2018-11-22 22:16:20 +08:00
|
|
|
class Device;
|
|
|
|
class ExecutionEnvironment;
|
|
|
|
class GraphicsAllocation;
|
|
|
|
class InternalAllocationStorage;
|
|
|
|
class MemoryManager;
|
|
|
|
struct HardwareInfo;
|
2019-09-16 20:59:54 +08:00
|
|
|
class OsContext;
|
2021-06-09 20:02:35 +08:00
|
|
|
class CommandStreamReceiver;
|
2018-11-22 22:16:20 +08:00
|
|
|
|
2019-08-23 17:17:09 +08:00
|
|
|
namespace ScratchSpaceConstants {
|
2022-12-08 22:23:49 +08:00
|
|
|
inline constexpr size_t scratchSpaceOffsetFor64Bit = 4096u;
|
2019-08-23 17:17:09 +08:00
|
|
|
}
|
|
|
|
|
2021-01-11 19:30:28 +08:00
|
|
|
using ResidencyContainer = std::vector<GraphicsAllocation *>;
|
|
|
|
|
2018-11-22 22:16:20 +08:00
|
|
|
class ScratchSpaceController {
|
|
|
|
public:
|
2019-11-07 21:15:04 +08:00
|
|
|
ScratchSpaceController(uint32_t rootDeviceIndex, ExecutionEnvironment &environment, InternalAllocationStorage &allocationStorage);
|
2018-11-22 22:16:20 +08:00
|
|
|
virtual ~ScratchSpaceController();
|
|
|
|
|
2020-10-07 18:07:34 +08:00
|
|
|
MOCKABLE_VIRTUAL GraphicsAllocation *getScratchSpaceAllocation() {
|
2018-11-22 22:16:20 +08:00
|
|
|
return scratchAllocation;
|
|
|
|
}
|
2019-06-27 18:59:27 +08:00
|
|
|
GraphicsAllocation *getPrivateScratchSpaceAllocation() {
|
|
|
|
return privateScratchAllocation;
|
|
|
|
}
|
2018-11-22 22:16:20 +08:00
|
|
|
virtual void setRequiredScratchSpace(void *sshBaseAddress,
|
2020-10-05 17:39:15 +08:00
|
|
|
uint32_t scratchSlot,
|
2018-11-22 22:16:20 +08:00
|
|
|
uint32_t requiredPerThreadScratchSize,
|
2019-06-27 18:59:27 +08:00
|
|
|
uint32_t requiredPerThreadPrivateScratchSize,
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType currentTaskCount,
|
2019-09-16 20:59:54 +08:00
|
|
|
OsContext &osContext,
|
2018-11-22 22:16:20 +08:00
|
|
|
bool &stateBaseAddressDirty,
|
|
|
|
bool &vfeStateDirty) = 0;
|
2020-12-07 23:38:12 +08:00
|
|
|
|
2018-11-22 22:16:20 +08:00
|
|
|
virtual uint64_t calculateNewGSH() = 0;
|
|
|
|
virtual uint64_t getScratchPatchAddress() = 0;
|
2021-01-15 22:48:38 +08:00
|
|
|
inline uint32_t getPerThreadScratchSpaceSize() {
|
|
|
|
return static_cast<uint32_t>(scratchSizeBytes / computeUnitsUsedForScratch);
|
|
|
|
}
|
2021-12-17 11:18:45 +08:00
|
|
|
inline uint32_t getPerThreadPrivateScratchSize() {
|
|
|
|
return static_cast<uint32_t>(privateScratchSizeBytes / computeUnitsUsedForScratch);
|
|
|
|
}
|
2018-11-22 22:16:20 +08:00
|
|
|
|
|
|
|
virtual void reserveHeap(IndirectHeap::Type heapType, IndirectHeap *&indirectHeap) = 0;
|
2020-10-05 17:39:15 +08:00
|
|
|
virtual void programHeaps(HeapContainer &heapContainer,
|
|
|
|
uint32_t scratchSlot,
|
|
|
|
uint32_t requiredPerThreadScratchSize,
|
|
|
|
uint32_t requiredPerThreadPrivateScratchSize,
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType currentTaskCount,
|
2020-10-05 17:39:15 +08:00
|
|
|
OsContext &osContext,
|
|
|
|
bool &stateBaseAddressDirty,
|
|
|
|
bool &vfeStateDirty) = 0;
|
2020-12-07 23:38:12 +08:00
|
|
|
virtual void programBindlessSurfaceStateForScratch(BindlessHeapsHelper *heapsHelper,
|
|
|
|
uint32_t requiredPerThreadScratchSize,
|
|
|
|
uint32_t requiredPerThreadPrivateScratchSize,
|
2022-11-22 21:53:59 +08:00
|
|
|
TaskCountType currentTaskCount,
|
2020-12-07 23:38:12 +08:00
|
|
|
OsContext &osContext,
|
|
|
|
bool &stateBaseAddressDirty,
|
2021-01-11 19:30:28 +08:00
|
|
|
bool &vfeStateDirty,
|
2021-06-09 20:02:35 +08:00
|
|
|
CommandStreamReceiver *csr) = 0;
|
2018-11-22 22:16:20 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
MemoryManager *getMemoryManager() const;
|
|
|
|
|
2019-11-07 21:15:04 +08:00
|
|
|
const uint32_t rootDeviceIndex;
|
2018-11-22 22:16:20 +08:00
|
|
|
ExecutionEnvironment &executionEnvironment;
|
|
|
|
GraphicsAllocation *scratchAllocation = nullptr;
|
2019-06-27 18:59:27 +08:00
|
|
|
GraphicsAllocation *privateScratchAllocation = nullptr;
|
2018-11-22 22:16:20 +08:00
|
|
|
InternalAllocationStorage &csrAllocationStorage;
|
|
|
|
size_t scratchSizeBytes = 0;
|
2019-06-27 18:59:27 +08:00
|
|
|
size_t privateScratchSizeBytes = 0;
|
2018-11-22 22:16:20 +08:00
|
|
|
bool force32BitAllocation = false;
|
|
|
|
uint32_t computeUnitsUsedForScratch = 0;
|
|
|
|
};
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|