1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/debugger/debugger.h"
#include "shared/source/helpers/non_copyable_or_moveable.h"
#include "shared/source/memory_manager/memory_manager.h"
#include <memory>
#include <unordered_map>
namespace NEO {
class Device;
class GraphicsAllocation;
class LinearStream;
} // namespace NEO
namespace L0 {
#pragma pack(1)
struct SbaTrackedAddresses {
char magic[8] = "sbaarea";
uint64_t Reserved1 = 0;
uint8_t Version = 0;
uint8_t Reserved2[7];
uint64_t GeneralStateBaseAddress = 0;
uint64_t SurfaceStateBaseAddress = 0;
uint64_t DynamicStateBaseAddress = 0;
uint64_t IndirectObjectBaseAddress = 0;
uint64_t InstructionBaseAddress = 0;
uint64_t BindlessSurfaceStateBaseAddress = 0;
uint64_t BindlessSamplerStateBaseAddress = 0;
};
struct DebugAreaHeader {
char magic[8] = "dbgarea";
uint64_t reserved1;
uint8_t version;
uint8_t pgsize;
uint8_t size;
uint8_t reserved2;
uint16_t scratchBegin;
uint16_t scratchEnd;
uint64_t isShared : 1;
};
#pragma pack()
class DebuggerL0 : public NEO::Debugger, NEO::NonCopyableOrMovableClass {
public:
static std::unique_ptr<Debugger> create(NEO::Device *device);
bool isDebuggerActive() override;
DebuggerL0(NEO::Device *device);
~DebuggerL0() override;
NEO::GraphicsAllocation *getSbaTrackingBuffer(uint32_t contextId) {
return perContextSbaAllocations[contextId];
}
NEO::GraphicsAllocation *getModuleDebugArea() {
return moduleDebugArea;
}
uint64_t getSbaTrackingGpuVa() {
return sbaTrackingGpuVa.address;
}
void captureStateBaseAddress(NEO::CommandContainer &container, SbaAddresses sba) override;
void printTrackedAddresses(uint32_t contextId);
virtual size_t getSbaTrackingCommandsSize(size_t trackedAddressCount) const = 0;
virtual void programSbaTrackingCommands(NEO::LinearStream &cmdStream, const SbaAddresses &sba) const = 0;
protected:
static bool isAnyTrackedAddressChanged(SbaAddresses sba) {
return sba.GeneralStateBaseAddress != 0 ||
sba.SurfaceStateBaseAddress != 0 ||
sba.BindlessSurfaceStateBaseAddress != 0;
}
MOCKABLE_VIRTUAL void registerResourceClasses();
NEO::Device *device = nullptr;
NEO::GraphicsAllocation *sbaAllocation = nullptr;
std::unordered_map<uint32_t, NEO::GraphicsAllocation *> perContextSbaAllocations;
NEO::AddressRange sbaTrackingGpuVa;
NEO::GraphicsAllocation *moduleDebugArea = nullptr;
};
using DebugerL0CreateFn = DebuggerL0 *(*)(NEO::Device *device);
extern DebugerL0CreateFn debuggerL0Factory[];
template <typename GfxFamily>
class DebuggerL0Hw : public DebuggerL0 {
public:
static DebuggerL0 *allocate(NEO::Device *device);
size_t getSbaTrackingCommandsSize(size_t trackedAddressCount) const override;
void programSbaTrackingCommands(NEO::LinearStream &cmdStream, const SbaAddresses &sba) const override;
protected:
DebuggerL0Hw(NEO::Device *device) : DebuggerL0(device){};
};
template <uint32_t productFamily, typename GfxFamily>
struct DebuggerL0PopulateFactory {
DebuggerL0PopulateFactory() {
debuggerL0Factory[productFamily] = DebuggerL0Hw<GfxFamily>::allocate;
}
};
} // namespace L0
|