1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:57:35 +00:00

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.
This commit is contained in:
Stephan Unverwerth 2022-09-14 23:48:10 +02:00 committed by Andrew Kaster
parent 4ad41e6680
commit 93ab2db80f
11 changed files with 96 additions and 3 deletions

View file

@ -4,6 +4,7 @@ set(SOURCES
Image.cpp
PixelConverter.cpp
Sampler.cpp
Shader.cpp
)
add_compile_options(-Wno-psabi)

View file

@ -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);

View file

@ -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;

View file

@ -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)
{
}
}

View file

@ -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);
};
}