diff options
author | Stephan Unverwerth <s.unverwerth@serenityos.org> | 2022-08-28 19:22:02 +0200 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-17 22:39:09 -0700 |
commit | 5f0eb812ac1d1dcface444049c35feb78ad885f4 (patch) | |
tree | 24b36ce1431e7fe4b145406cb3893800708b96b6 /Userland/Libraries/LibGPU | |
parent | 1b7b6e6c918406613e6a9ea2226725c59bc8b6ee (diff) | |
download | serenity-5f0eb812ac1d1dcface444049c35feb78ad885f4.zip |
LibGPU: Add basic shader IR
This adds a header to LibGPU with a basic IR for vertex and fragment
shaders.
Diffstat (limited to 'Userland/Libraries/LibGPU')
-rw-r--r-- | Userland/Libraries/LibGPU/IR.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGPU/IR.h b/Userland/Libraries/LibGPU/IR.h new file mode 100644 index 0000000000..c882612b77 --- /dev/null +++ b/Userland/Libraries/LibGPU/IR.h @@ -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; +}; + +} |