File: blit_commands_helper_pvc_and_later.inl

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 (105 lines) | stat: -rw-r--r-- 4,167 bytes parent folder | download
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
/*
 * Copyright (C) 2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/gmm_helper/resource_info.h"
#include "shared/source/helpers/blit_commands_helper.h"

namespace NEO {

template <typename GfxFamily>
size_t BlitCommandsHelper<GfxFamily>::getNumberOfBlitsForByteFill(const Vec3<size_t> &copySize, size_t patternSize, const RootDeviceEnvironment &rootDeviceEnvironment, bool isSystemMemoryPoolUsed) {
    auto maxWidthToFill = getMaxBlitSetWidth(rootDeviceEnvironment);
    auto maxHeightToFill = getMaxBlitSetHeight(rootDeviceEnvironment);
    auto nBlits = 0;
    uint64_t width = 1;
    uint64_t height = 1;
    uint64_t sizeToFill = copySize.x / patternSize;
    while (sizeToFill != 0) {
        if (sizeToFill <= maxWidthToFill) {
            width = sizeToFill;
            height = 1;
        } else {
            width = maxWidthToFill;
            height = std::min((sizeToFill / width), maxHeightToFill);
        }
        sizeToFill -= (width * height);
        nBlits++;
    }
    return nBlits;
}

template <typename GfxFamily>
BlitCommandsResult BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryByteFill(const BlitProperties &blitProperties, LinearStream &linearStream, RootDeviceEnvironment &rootDeviceEnvironment) {
    using MEM_SET = typename Family::MEM_SET;
    auto blitCmd = Family::cmdInitMemSet;
    const auto maxBlitSetWidth = getMaxBlitSetWidth(rootDeviceEnvironment);
    const auto maxBlitSetHeight = getMaxBlitSetHeight(rootDeviceEnvironment);

    auto mocs = rootDeviceEnvironment.getGmmHelper()->getL3EnabledMOCS();
    if (debugManager.flags.OverrideBlitterMocs.get() != -1) {
        mocs = static_cast<uint32_t>(debugManager.flags.OverrideBlitterMocs.get());
    }
    blitCmd.setDestinationMOCS(mocs);

    uint32_t compressionFormat = 0;

    if (blitProperties.dstAllocation) {
        if (blitProperties.dstAllocation->isCompressionEnabled()) {
            auto resourceFormat = blitProperties.dstAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
            compressionFormat = static_cast<uint32_t>(rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat));
        }

        appendBlitMemSetCompressionFormat(&blitCmd, blitProperties.dstAllocation, compressionFormat);
    }
    blitCmd.setFillData(*blitProperties.fillPattern);

    const bool useAdditionalBlitProperties = rootDeviceEnvironment.getHelper<ProductHelper>().useAdditionalBlitProperties();

    uint64_t sizeToFill = blitProperties.copySize.x;
    uint64_t offset = blitProperties.dstOffset.x;
    BlitCommandsResult result{};
    bool firstCommand = true;
    while (sizeToFill != 0) {
        auto tmpCmd = blitCmd;
        tmpCmd.setDestinationStartAddress(ptrOffset(blitProperties.dstGpuAddress, static_cast<size_t>(offset)));
        uint64_t height = 0;
        uint64_t width = 0;
        if (sizeToFill <= maxBlitSetWidth) {
            width = sizeToFill;
            height = 1;
        } else {
            width = maxBlitSetWidth;
            height = std::min<uint64_t>((sizeToFill / width), maxBlitSetHeight);
            if (height > 1) {
                tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL);
            }
        }
        auto blitSize = static_cast<uint64_t>(width * height);
        auto lastCommand = (sizeToFill - blitSize == 0);
        tmpCmd.setFillWidth(static_cast<uint32_t>(width));
        tmpCmd.setFillHeight(static_cast<uint32_t>(height));
        tmpCmd.setDestinationPitch(static_cast<uint32_t>(width));

        if (useAdditionalBlitProperties && (firstCommand || lastCommand)) {
            applyAdditionalBlitProperties(blitProperties, tmpCmd, rootDeviceEnvironment, lastCommand);
            firstCommand = false;
        }
        appendBlitMemSetCommand(blitProperties, &tmpCmd);

        auto cmd = linearStream.getSpaceForCmd<MEM_SET>();
        *cmd = tmpCmd;
        if (lastCommand) {
            result.lastBlitCommand = cmd;
        }
        offset += blitSize;
        sizeToFill -= blitSize;
    }
    return result;
}

} // namespace NEO