summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGPU/IR.h
blob: c983ce5068450b42b8464d7817250bd60e0f673d (plain)
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
/*
 * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/String.h>
#include <AK/Vector.h>

namespace GPU::IR {

enum class Opcode {
    Move,
};

enum class StorageLocation {
    Constant,
    Uniform,
    Input,
    Output,
    Temporary,
};

enum class StorageType {
    Float,
    Vector2,
    Vector3,
    Vector4,
    Matrix3x3,
    Matrix4x4,
};

struct StorageReference final {
    StorageLocation location;
    size_t index;
};

struct Instruction final {
    Opcode operation;
    Vector<StorageReference> arguments;
    StorageReference result;
};

struct Constant final {
    StorageType type;
    union {
        float float_values[16];
    };
};

struct Uniform final {
    String name;
    StorageType type;
};

struct Input final {
    String name;
    StorageType type;
};

struct Output final {
    String name;
    StorageType type;
};

struct Temporary final {
    StorageType type;
};

struct Shader final {
    Vector<Constant> constants;
    Vector<Uniform> uniforms;
    Vector<Input> inputs;
    Vector<Output> outputs;
    Vector<Temporary> temporaries;
    Vector<Instruction> instructions;
};

}