From 5f0eb812ac1d1dcface444049c35feb78ad885f4 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Sun, 28 Aug 2022 19:22:02 +0200 Subject: [PATCH] LibGPU: Add basic shader IR This adds a header to LibGPU with a basic IR for vertex and fragment shaders. --- Userland/Libraries/LibGPU/IR.h | 79 ++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Userland/Libraries/LibGPU/IR.h 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 + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +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 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 constants; + Vector uniforms; + Vector temporaries; + Vector instructions; +}; + +}