From 67b2f8d68dd8a9d0c87551650777700bd8f9d841 Mon Sep 17 00:00:00 2001 From: Stephan Unverwerth Date: Sun, 28 Aug 2022 19:23:30 +0200 Subject: [PATCH] LibGLSL: Add LibGLSL This adds a new library, LibGLSL for parsing and compiling GLSL programs to LibGPU IR. Currently the compiler consists only of stubs. --- Meta/Lagom/CMakeLists.txt | 1 + Userland/Libraries/CMakeLists.txt | 1 + Userland/Libraries/LibGL/CMakeLists.txt | 2 +- Userland/Libraries/LibGLSL/CMakeLists.txt | 7 ++++++ Userland/Libraries/LibGLSL/Compiler.cpp | 18 +++++++++++++++ Userland/Libraries/LibGLSL/Compiler.h | 27 ++++++++++++++++++++++ Userland/Libraries/LibGLSL/LinkedShader.h | 22 ++++++++++++++++++ Userland/Libraries/LibGLSL/Linker.cpp | 18 +++++++++++++++ Userland/Libraries/LibGLSL/Linker.h | 28 +++++++++++++++++++++++ Userland/Libraries/LibGLSL/ObjectFile.h | 16 +++++++++++++ 10 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 Userland/Libraries/LibGLSL/CMakeLists.txt create mode 100644 Userland/Libraries/LibGLSL/Compiler.cpp create mode 100644 Userland/Libraries/LibGLSL/Compiler.h create mode 100644 Userland/Libraries/LibGLSL/LinkedShader.h create mode 100644 Userland/Libraries/LibGLSL/Linker.cpp create mode 100644 Userland/Libraries/LibGLSL/Linker.h create mode 100644 Userland/Libraries/LibGLSL/ObjectFile.h diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index 3e1785b15c..0b3d046fe1 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -347,6 +347,7 @@ if (BUILD_LAGOM) Gemini Gfx GL + GLSL GPU HTTP IMAP diff --git a/Userland/Libraries/CMakeLists.txt b/Userland/Libraries/CMakeLists.txt index c1e7ac418a..232e79014b 100644 --- a/Userland/Libraries/CMakeLists.txt +++ b/Userland/Libraries/CMakeLists.txt @@ -23,6 +23,7 @@ add_subdirectory(LibFileSystemAccessClient) add_subdirectory(LibGemini) add_subdirectory(LibGfx) add_subdirectory(LibGL) +add_subdirectory(LibGLSL) add_subdirectory(LibGPU) add_subdirectory(LibGUI) add_subdirectory(LibHTTP) diff --git a/Userland/Libraries/LibGL/CMakeLists.txt b/Userland/Libraries/LibGL/CMakeLists.txt index 7b29573dee..88bd390fe9 100644 --- a/Userland/Libraries/LibGL/CMakeLists.txt +++ b/Userland/Libraries/LibGL/CMakeLists.txt @@ -20,4 +20,4 @@ set(SOURCES ) serenity_lib(LibGL gl) -target_link_libraries(LibGL PRIVATE LibCore LibGfx LibGPU) +target_link_libraries(LibGL PRIVATE LibCore LibGfx LibGLSL LibGPU) diff --git a/Userland/Libraries/LibGLSL/CMakeLists.txt b/Userland/Libraries/LibGLSL/CMakeLists.txt new file mode 100644 index 0000000000..7c57d8d9dc --- /dev/null +++ b/Userland/Libraries/LibGLSL/CMakeLists.txt @@ -0,0 +1,7 @@ +set(SOURCES + Compiler.cpp + Linker.cpp +) + +serenity_lib(LibGLSL glsl) +target_link_libraries(LibGLSL PRIVATE LibGPU) diff --git a/Userland/Libraries/LibGLSL/Compiler.cpp b/Userland/Libraries/LibGLSL/Compiler.cpp new file mode 100644 index 0000000000..797860513a --- /dev/null +++ b/Userland/Libraries/LibGLSL/Compiler.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022, Stephan Unverwerth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace GLSL { + +ErrorOr> Compiler::compile(Vector const&) +{ + // FIXME: implement this function + m_messages = TRY(String::from_utf8(""sv)); + return adopt_own(*new ObjectFile()); +} + +} diff --git a/Userland/Libraries/LibGLSL/Compiler.h b/Userland/Libraries/LibGLSL/Compiler.h new file mode 100644 index 0000000000..b4d4c4be36 --- /dev/null +++ b/Userland/Libraries/LibGLSL/Compiler.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022, Stephan Unverwerth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace GLSL { + +class Compiler final { +public: + ErrorOr> compile(Vector const& sources); + + String messages() const { return m_messages; } + +private: + String m_messages; +}; + +} diff --git a/Userland/Libraries/LibGLSL/LinkedShader.h b/Userland/Libraries/LibGLSL/LinkedShader.h new file mode 100644 index 0000000000..10fd4ffdf0 --- /dev/null +++ b/Userland/Libraries/LibGLSL/LinkedShader.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022, Stephan Unverwerth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace GLSL { + +// FIXME: Implement this class + +class LinkedShader final { +}; + +} diff --git a/Userland/Libraries/LibGLSL/Linker.cpp b/Userland/Libraries/LibGLSL/Linker.cpp new file mode 100644 index 0000000000..367bf93e05 --- /dev/null +++ b/Userland/Libraries/LibGLSL/Linker.cpp @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2022, Stephan Unverwerth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +namespace GLSL { + +ErrorOr> Linker::link(Vector const&) +{ + // FIXME: implement this function + m_messages = TRY(String::from_utf8(""sv)); + return adopt_own(*new LinkedShader()); +} + +} diff --git a/Userland/Libraries/LibGLSL/Linker.h b/Userland/Libraries/LibGLSL/Linker.h new file mode 100644 index 0000000000..90ac686969 --- /dev/null +++ b/Userland/Libraries/LibGLSL/Linker.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022, Stephan Unverwerth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace GLSL { + +class Linker final { +public: + ErrorOr> link(Vector const&); + + String messages() const { return m_messages; } + +private: + String m_messages; +}; + +} diff --git a/Userland/Libraries/LibGLSL/ObjectFile.h b/Userland/Libraries/LibGLSL/ObjectFile.h new file mode 100644 index 0000000000..da29541ac8 --- /dev/null +++ b/Userland/Libraries/LibGLSL/ObjectFile.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022, Stephan Unverwerth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +namespace GLSL { + +// FIXME: Implement this class + +class ObjectFile final { +}; + +}