LibSoftGPU: Delegate shader creation to new class ShaderCompiler

This commit is contained in:
Stephan Unverwerth 2022-09-18 16:32:09 +02:00 committed by Andrew Kaster
parent 5bab17596d
commit c25359df47
Notes: sideshowbarker 2024-07-17 03:01:02 +09:00
4 changed files with 44 additions and 2 deletions

View file

@ -3,6 +3,7 @@ set(SOURCES
Device.cpp
Image.cpp
PixelConverter.cpp
ShaderCompiler.cpp
ShaderProcessor.cpp
Sampler.cpp
Shader.cpp

View file

@ -23,6 +23,7 @@
#include <LibSoftGPU/PixelQuad.h>
#include <LibSoftGPU/SIMD.h>
#include <LibSoftGPU/Shader.h>
#include <LibSoftGPU/ShaderCompiler.h>
#include <math.h>
namespace SoftGPU {
@ -1642,9 +1643,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&)
ErrorOr<NonnullRefPtr<GPU::Shader>> Device::create_shader(GPU::IR::Shader const& intermediate_representation)
{
return adopt_ref(*new Shader(this, {}));
ShaderCompiler compiler;
auto shader = TRY(compiler.compile(this, intermediate_representation));
return shader;
}
void Device::set_sampler_config(unsigned sampler, GPU::SamplerConfig const& config)

View file

@ -0,0 +1,17 @@
/*
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibSoftGPU/ShaderCompiler.h>
namespace SoftGPU {
ErrorOr<NonnullRefPtr<Shader>> ShaderCompiler::compile(void const* ownership_token, GPU::IR::Shader const&)
{
// FIXME: implement the shader compiler
return adopt_ref(*new Shader(ownership_token, {}));
}
}

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Error.h>
#include <AK/NonnullRefPtr.h>
#include <LibGPU/IR.h>
#include <LibSoftGPU/Shader.h>
namespace SoftGPU {
class ShaderCompiler final {
public:
ErrorOr<NonnullRefPtr<Shader>> compile(void const* ownership_token, GPU::IR::Shader const&);
};
}