diff options
author | Stephan Unverwerth <s.unverwerth@serenityos.org> | 2022-09-14 23:48:10 +0200 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-17 22:39:09 -0700 |
commit | 93ab2db80fed38b6e621085b5e060ae726d77a88 (patch) | |
tree | 5e0f4fd00f777dd60b932af8c3c52833e9752ee0 /Userland/Libraries/LibGPU | |
parent | 4ad41e6680bad5397ab9f16110514268673c3ab2 (diff) | |
download | serenity-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/LibGPU')
-rw-r--r-- | Userland/Libraries/LibGPU/Device.h | 3 | ||||
-rw-r--r-- | Userland/Libraries/LibGPU/Shader.h | 29 |
2 files changed, 32 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGPU/Device.h b/Userland/Libraries/LibGPU/Device.h index 7b08f315c5..d2a7a112d9 100644 --- a/Userland/Libraries/LibGPU/Device.h +++ b/Userland/Libraries/LibGPU/Device.h @@ -12,6 +12,7 @@ #include <AK/Vector.h> #include <LibGPU/DeviceInfo.h> #include <LibGPU/Enums.h> +#include <LibGPU/IR.h> #include <LibGPU/Image.h> #include <LibGPU/ImageDataLayout.h> #include <LibGPU/Light.h> @@ -20,6 +21,7 @@ #include <LibGPU/RasterPosition.h> #include <LibGPU/RasterizerOptions.h> #include <LibGPU/SamplerConfig.h> +#include <LibGPU/Shader.h> #include <LibGPU/StencilConfiguration.h> #include <LibGPU/TextureUnitConfiguration.h> #include <LibGPU/Vertex.h> @@ -56,6 +58,7 @@ public: virtual LightModelParameters light_model() const = 0; virtual NonnullRefPtr<Image> create_image(PixelFormat const&, u32 width, u32 height, u32 depth, u32 max_levels) = 0; + virtual ErrorOr<NonnullRefPtr<Shader>> create_shader(IR::Shader const&) = 0; virtual void set_sampler_config(unsigned, SamplerConfig const&) = 0; virtual void set_light_state(unsigned, Light const&) = 0; diff --git a/Userland/Libraries/LibGPU/Shader.h b/Userland/Libraries/LibGPU/Shader.h new file mode 100644 index 0000000000..c96a8d0dea --- /dev/null +++ b/Userland/Libraries/LibGPU/Shader.h @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/RefCounted.h> + +namespace GPU { + +class Shader : public RefCounted<Shader> { +public: + Shader(void const* ownership_token) + : m_ownership_token { ownership_token } + { + } + + virtual ~Shader() = default; + + void const* ownership_token() const { return m_ownership_token; } + bool has_same_ownership_token(Shader const& other) const { return other.ownership_token() == ownership_token(); } + +private: + void const* const m_ownership_token { nullptr }; +}; + +} |