| 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 |
#pragma once |
| 27 |
|
| 28 |
#include "cm_hal.h" |
| 29 |
#include "heap_manager.h" |
| 30 |
#include <list> |
| 31 |
|
| 32 |
class CmKernelEx; |
| 33 |
namespace CMRT_UMD |
| 34 |
{ |
| 35 |
class CmThreadGroupSpace; |
| 36 |
}; |
| 37 |
|
| 38 |
class CmMediaState |
| 39 |
{ |
| 40 |
public: |
| 41 |
CmMediaState(CM_HAL_STATE *cmhal); |
| 42 |
~CmMediaState(); |
| 43 |
|
| 44 |
MOS_STATUS Initialize(HeapManager *heapMgr); |
| 45 |
|
| 46 |
MOS_STATUS Allocate(CmKernelEx **kernels, int count, uint32_t trackerIndex, uint32_t trackerID); |
| 47 |
|
| 48 |
inline MOS_RESOURCE* GetHeapResource() {return m_memoryBlock.GetResource(); } |
| 49 |
|
| 50 |
inline uint32_t GetCurbeOffset() {return m_curbeOffsetInternal + m_memoryBlock.GetOffset();} |
| 51 |
|
| 52 |
inline uint32_t GetCurbeOffset(uint32_t kernelIndex) {return m_curbeOffsets[kernelIndex] + m_curbeOffsetInternal + m_memoryBlock.GetOffset();} |
| 53 |
|
| 54 |
inline uint32_t GetMediaIDOffset() {return m_mediaIDOffsetInternal + m_memoryBlock.GetOffset();} |
| 55 |
|
| 56 |
inline uint32_t GetHeapSize() {return m_memoryBlock.GetHeapSize(); } |
| 57 |
|
| 58 |
inline uint32_t GetCurbeSize() {return m_totalCurbeSize; } |
| 59 |
|
| 60 |
inline uint32_t GetMediaIDSize() {return m_totalMediaIDSize;} |
| 61 |
|
| 62 |
inline uint32_t GetSamplerHeapOffset(uint32_t kernelIndex) {return m_samplerOffsets[kernelIndex] + m_samplerHeapOffsetInternal + m_memoryBlock.GetOffset();} |
| 63 |
|
| 64 |
inline uint32_t GetSamplerCount(uint32_t kernelIndex) {return m_samplerCount[kernelIndex]; } |
| 65 |
|
| 66 |
inline uint32_t GetScratchSizePerThread() {return m_scratchSizePerThread; } |
| 67 |
|
| 68 |
inline uint32_t GetScratchSpaceOffset() {return m_scratchSpaceOffsetExternal; } |
| 69 |
|
| 70 |
MOS_STATUS LoadCurbe(CmKernelEx *kernel, int index); |
| 71 |
|
| 72 |
MOS_STATUS LoadCurbe(uint8_t *curbe, uint32_t size, int index); |
| 73 |
|
| 74 |
MOS_STATUS LoadMediaID(CmKernelEx *kernel, int index, uint32_t btOffset, CMRT_UMD::CmThreadGroupSpace *threadGroupSpace = nullptr); |
| 75 |
|
| 76 |
int AddSampler(void *samplerParam, int index, int bteIndex = -1); |
| 77 |
|
| 78 |
MOS_STATUS Submit(); |
| 79 |
|
| 80 |
void Dump(); |
| 81 |
|
| 82 |
protected: |
| 83 |
|
| 84 |
MOS_STATUS PrepareMemoryBlock(uint32_t size, uint32_t trackerIndex, uint32_t trackerID); |
| 85 |
|
| 86 |
uint32_t UpdateHeapSizeAndOffsets(CmKernelEx *kernel, uint32_t kernelIdx); |
| 87 |
|
| 88 |
enum _BlockState |
| 89 |
{ |
| 90 |
_Empty, |
| 91 |
_Allocated, |
| 92 |
_Submitted |
| 93 |
}; |
| 94 |
|
| 95 |
CM_HAL_STATE *m_cmhal; |
| 96 |
HeapManager *m_heapMgr; |
| 97 |
|
| 98 |
MemoryBlock m_memoryBlock; |
| 99 |
|
| 100 |
uint32_t m_curbeOffsetInternal; |
| 101 |
uint32_t m_mediaIDOffsetInternal; |
| 102 |
uint32_t m_samplerHeapOffsetInternal; |
| 103 |
uint32_t m_scratchSpaceOffsetExternal; |
| 104 |
|
| 105 |
uint32_t m_totalCurbeSize; |
| 106 |
uint32_t m_totalMediaIDSize; |
| 107 |
uint32_t m_totalSamplerHeapSize; |
| 108 |
uint32_t m_totalScratchSpaceSize; |
| 109 |
|
| 110 |
uint32_t m_curbeOffsets[CM_MAX_KERNELS_PER_TASK]; |
| 111 |
uint32_t m_samplerOffsets[CM_MAX_KERNELS_PER_TASK]; |
| 112 |
uint32_t m_next3dSamplerOffsets[CM_MAX_KERNELS_PER_TASK]; |
| 113 |
uint32_t m_nextAvsSamplerOffsets[CM_MAX_KERNELS_PER_TASK]; |
| 114 |
uint32_t m_nextIndStateOffsets[CM_MAX_KERNELS_PER_TASK]; |
| 115 |
uint32_t m_samplerCount[CM_MAX_KERNELS_PER_TASK]; |
| 116 |
uint32_t m_mediaIDSize; |
| 117 |
uint32_t m_scratchSizePerThread; |
| 118 |
|
| 119 |
_BlockState m_state; |
| 120 |
|
| 121 |
const uint32_t m_3dSamplerElementSize = 16; |
| 122 |
const uint32_t m_avsSamplerElementSize = 2048; |
| 123 |
|
| 124 |
}; |