File: surface.cpp

package info (click to toggle)
intel-compute-runtime 25.35.35096.9-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 79,324 kB
  • sloc: cpp: 926,243; lisp: 3,433; sh: 715; makefile: 162; python: 21
file content (57 lines) | stat: -rw-r--r-- 1,852 bytes parent folder | download | duplicates (2)
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
/*
 * Copyright (C) 2023 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/source/memory_manager/surface.h"

#include "shared/source/command_stream/command_stream_receiver.h"
#include "shared/source/helpers/cache_policy.h"
#include "shared/source/memory_manager/graphics_allocation.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/page_fault_manager/cpu_page_fault_manager.h"

namespace NEO {

HostPtrSurface::HostPtrSurface(const void *ptr, size_t size) : memoryPointer(ptr), surfaceSize(size) {
    UNRECOVERABLE_IF(!ptr);
    gfxAllocation = nullptr;
}

HostPtrSurface::HostPtrSurface(const void *ptr, size_t size, GraphicsAllocation *allocation) : memoryPointer(ptr), surfaceSize(size), gfxAllocation(allocation) {
    DEBUG_BREAK_IF(!ptr);
}

void HostPtrSurface::makeResident(CommandStreamReceiver &csr) {
    DEBUG_BREAK_IF(!gfxAllocation);
    gfxAllocation->prepareHostPtrForResidency(&csr);
    csr.makeResidentHostPtrAllocation(gfxAllocation);
}

bool HostPtrSurface::allowsL3Caching() {
    return isL3Capable(*gfxAllocation);
}

GeneralSurface::GeneralSurface(GraphicsAllocation *gfxAlloc) : Surface(gfxAlloc->isCoherent()) {
    gfxAllocation = gfxAlloc;
}

GeneralSurface::GeneralSurface(GraphicsAllocation *gfxAlloc, bool needsMigration) : GeneralSurface(gfxAlloc) {
    this->needsMigration = needsMigration;
}

void GeneralSurface::makeResident(CommandStreamReceiver &csr) {
    if (needsMigration) {
        csr.getMemoryManager()->getPageFaultManager()->moveAllocationToGpuDomain(reinterpret_cast<void *>(gfxAllocation->getGpuAddress()));
    }
    csr.makeResident(*gfxAllocation);
};

void GeneralSurface::setGraphicsAllocation(GraphicsAllocation *newAllocation) {
    gfxAllocation = newAllocation;
    isCoherent = newAllocation->isCoherent();
}

} // namespace NEO