| 1 |
/* |
| 2 |
* Copyright (C) 2023 Intel Corporation |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
* |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "shared/source/gmm_helper/client_context/gmm_client_context.h" |
| 9 |
#include "shared/source/gmm_helper/client_context/map_gpu_va_gmm.h" |
| 10 |
#include "shared/source/gmm_helper/resource_info.h" |
| 11 |
#include "shared/source/os_interface/windows/gdi_interface.h" |
| 12 |
|
| 13 |
namespace NEO { |
| 14 |
uint64_t GmmClientContext::mapGpuVirtualAddress(MapGpuVirtualAddressGmm *pMapGpuVa) { |
| 15 |
auto gmmResourceFlags = pMapGpuVa->resourceInfoHandle->getResourceFlags()->Info; |
| 16 |
if (gmmResourceFlags.MediaCompressed || gmmResourceFlags.RenderCompressed) { |
| 17 |
auto gmmResourceInfo = pMapGpuVa->resourceInfoHandle->peekGmmResourceInfo(); |
| 18 |
GMM_MAPGPUVIRTUALADDRESS gmmMapAddress = {pMapGpuVa->mapGpuVirtualAddressParams, 1, &gmmResourceInfo, pMapGpuVa->outVirtualAddress}; |
| 19 |
return clientContext->MapGpuVirtualAddress(&gmmMapAddress); |
| 20 |
} else { |
| 21 |
return pMapGpuVa->gdi->mapGpuVirtualAddress(pMapGpuVa->mapGpuVirtualAddressParams); |
| 22 |
} |
| 23 |
} |
| 24 |
uint64_t GmmClientContext::freeGpuVirtualAddress(FreeGpuVirtualAddressGmm *pFreeGpuVa) { |
| 25 |
auto gmmResourceFlags = pFreeGpuVa->resourceInfoHandle->getResourceFlags()->Info; |
| 26 |
if (gmmResourceFlags.MediaCompressed || gmmResourceFlags.RenderCompressed) { |
| 27 |
auto gmmResourceInfo = pFreeGpuVa->resourceInfoHandle->peekGmmResourceInfo(); |
| 28 |
GMM_FREEGPUVIRTUALADDRESS gmmFreeAddress = {pFreeGpuVa->hAdapter, pFreeGpuVa->baseAddress, pFreeGpuVa->size, 1, &gmmResourceInfo}; |
| 29 |
return clientContext->FreeGpuVirtualAddress(&gmmFreeAddress); |
| 30 |
} else { |
| 31 |
return 0; |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
} // namespace NEO |