summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibSoftGPU
diff options
context:
space:
mode:
authorStephan Unverwerth <s.unverwerth@serenityos.org>2022-09-14 23:48:10 +0200
committerAndrew Kaster <andrewdkaster@gmail.com>2022-12-17 22:39:09 -0700
commit93ab2db80fed38b6e621085b5e060ae726d77a88 (patch)
tree5e0f4fd00f777dd60b932af8c3c52833e9752ee0 /Userland/Libraries/LibSoftGPU
parent4ad41e6680bad5397ab9f16110514268673c3ab2 (diff)
downloadserenity-93ab2db80fed38b6e621085b5e060ae726d77a88.zip
LibGL+LibSoftGPU: Add GPU side shader infrastructure
This adds a shader class to LibSoftGPU and makes use of it when linking GLSL program in LibGL. Also adds actual rendering code to the shader tests.
Diffstat (limited to 'Userland/Libraries/LibSoftGPU')
-rw-r--r--Userland/Libraries/LibSoftGPU/CMakeLists.txt1
-rw-r--r--Userland/Libraries/LibSoftGPU/Device.cpp6
-rw-r--r--Userland/Libraries/LibSoftGPU/Device.h1
-rw-r--r--Userland/Libraries/LibSoftGPU/Shader.cpp16
-rw-r--r--Userland/Libraries/LibSoftGPU/Shader.h18
5 files changed, 42 insertions, 0 deletions
diff --git a/Userland/Libraries/LibSoftGPU/CMakeLists.txt b/Userland/Libraries/LibSoftGPU/CMakeLists.txt
index 3dbe3b6725..c97b476e30 100644
--- a/Userland/Libraries/LibSoftGPU/CMakeLists.txt
+++ b/Userland/Libraries/LibSoftGPU/CMakeLists.txt
@@ -4,6 +4,7 @@ set(SOURCES
Image.cpp
PixelConverter.cpp
Sampler.cpp
+ Shader.cpp
)
add_compile_options(-Wno-psabi)
diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp
index c3085a9328..318617d7e6 100644
--- a/Userland/Libraries/LibSoftGPU/Device.cpp
+++ b/Userland/Libraries/LibSoftGPU/Device.cpp
@@ -22,6 +22,7 @@
#include <LibSoftGPU/PixelConverter.h>
#include <LibSoftGPU/PixelQuad.h>
#include <LibSoftGPU/SIMD.h>
+#include <LibSoftGPU/Shader.h>
#include <math.h>
namespace SoftGPU {
@@ -1626,6 +1627,11 @@ NonnullRefPtr<GPU::Image> Device::create_image(GPU::PixelFormat const& pixel_for
return adopt_ref(*new Image(this, pixel_format, width, height, depth, max_levels));
}
+ErrorOr<NonnullRefPtr<GPU::Shader>> Device::create_shader(GPU::IR::Shader const&)
+{
+ return adopt_ref(*new Shader(this));
+}
+
void Device::set_sampler_config(unsigned sampler, GPU::SamplerConfig const& config)
{
VERIFY(config.bound_image.is_null() || config.bound_image->ownership_token() == this);
diff --git a/Userland/Libraries/LibSoftGPU/Device.h b/Userland/Libraries/LibSoftGPU/Device.h
index c772814d03..027a81d081 100644
--- a/Userland/Libraries/LibSoftGPU/Device.h
+++ b/Userland/Libraries/LibSoftGPU/Device.h
@@ -65,6 +65,7 @@ public:
virtual GPU::LightModelParameters light_model() const override { return m_lighting_model; }
virtual NonnullRefPtr<GPU::Image> create_image(GPU::PixelFormat const&, u32 width, u32 height, u32 depth, u32 max_levels) override;
+ virtual ErrorOr<NonnullRefPtr<GPU::Shader>> create_shader(GPU::IR::Shader const&) override;
virtual void set_sampler_config(unsigned, GPU::SamplerConfig const&) override;
virtual void set_light_state(unsigned, GPU::Light const&) override;
diff --git a/Userland/Libraries/LibSoftGPU/Shader.cpp b/Userland/Libraries/LibSoftGPU/Shader.cpp
new file mode 100644
index 0000000000..44bb9635ea
--- /dev/null
+++ b/Userland/Libraries/LibSoftGPU/Shader.cpp
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibSoftGPU/Shader.h>
+
+namespace SoftGPU {
+
+Shader::Shader(void const* ownership_token)
+ : GPU::Shader(ownership_token)
+{
+}
+
+}
diff --git a/Userland/Libraries/LibSoftGPU/Shader.h b/Userland/Libraries/LibSoftGPU/Shader.h
new file mode 100644
index 0000000000..7c6b899d05
--- /dev/null
+++ b/Userland/Libraries/LibSoftGPU/Shader.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibGPU/Shader.h>
+
+namespace SoftGPU {
+
+class Shader final : public GPU::Shader {
+public:
+ Shader(void const* ownership_token);
+};
+
+}