mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:07:45 +00:00
LibGPU: Add basic shader IR
This adds a header to LibGPU with a basic IR for vertex and fragment shaders.
This commit is contained in:
parent
1b7b6e6c91
commit
5f0eb812ac
1 changed files with 79 additions and 0 deletions
79
Userland/Libraries/LibGPU/IR.h
Normal file
79
Userland/Libraries/LibGPU/IR.h
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* 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<Temporary> temporaries;
|
||||||
|
Vector<Instruction> instructions;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue