File: state_base_address_tests.h

package info (click to toggle)
intel-compute-runtime 22.43.24595.41-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 57,740 kB
  • sloc: cpp: 631,142; lisp: 3,515; sh: 470; makefile: 76; python: 21
file content (72 lines) | stat: -rw-r--r-- 2,392 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
/*
 * Copyright (C) 2021-2022 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once

#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/helpers/state_base_address.h"
#include "shared/source/indirect_heap/indirect_heap.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"

#include "gtest/gtest.h"

struct SbaTest : public NEO::DeviceFixture, public ::testing::Test {
    void SetUp() override {
        NEO::DeviceFixture::setUp();
        size_t sizeStream = 512;
        size_t alignmentStream = 0x1000;

        sshBuffer = alignedMalloc(sizeStream, alignmentStream);
        ASSERT_NE(nullptr, sshBuffer);
        ssh.replaceBuffer(sshBuffer, sizeStream);
        auto graphicsAllocation = new MockGraphicsAllocation(sshBuffer, sizeStream);
        ssh.replaceGraphicsAllocation(graphicsAllocation);

        dshBuffer = alignedMalloc(sizeStream, alignmentStream);
        ASSERT_NE(nullptr, dshBuffer);
        dsh.replaceBuffer(dshBuffer, sizeStream);
        graphicsAllocation = new MockGraphicsAllocation(dshBuffer, sizeStream);
        dsh.replaceGraphicsAllocation(graphicsAllocation);

        iohBuffer = alignedMalloc(sizeStream, alignmentStream);
        ASSERT_NE(nullptr, iohBuffer);
        ioh.replaceBuffer(iohBuffer, sizeStream);
        graphicsAllocation = new MockGraphicsAllocation(iohBuffer, sizeStream);
        ioh.replaceGraphicsAllocation(graphicsAllocation);

        linearStreamBuffer = alignedMalloc(sizeStream, alignmentStream);
        commandStream.replaceBuffer(linearStreamBuffer, alignmentStream);
    }

    void TearDown() override {
        alignedFree(linearStreamBuffer);

        delete ssh.getGraphicsAllocation();
        alignedFree(sshBuffer);

        delete dsh.getGraphicsAllocation();
        alignedFree(dshBuffer);

        delete ioh.getGraphicsAllocation();
        alignedFree(iohBuffer);

        NEO::DeviceFixture::tearDown();
    }
    IndirectHeap ssh = {nullptr};
    IndirectHeap dsh = {nullptr};
    IndirectHeap ioh = {nullptr};

    DebugManagerStateRestore restorer;
    LinearStream commandStream;

    void *sshBuffer = nullptr;
    void *dshBuffer = nullptr;
    void *iohBuffer = nullptr;
    void *linearStreamBuffer = nullptr;
};