mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibSoftGPU: Delegate shader creation to new class ShaderCompiler
This commit is contained in:
parent
5bab17596d
commit
c25359df47
Notes:
sideshowbarker
2024-07-17 03:01:02 +09:00
Author: https://github.com/sunverwerth Commit: https://github.com/SerenityOS/serenity/commit/c25359df47 Pull-request: https://github.com/SerenityOS/serenity/pull/16225 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/supercomputer7
4 changed files with 44 additions and 2 deletions
|
@ -3,6 +3,7 @@ set(SOURCES
|
|||
Device.cpp
|
||||
Image.cpp
|
||||
PixelConverter.cpp
|
||||
ShaderCompiler.cpp
|
||||
ShaderProcessor.cpp
|
||||
Sampler.cpp
|
||||
Shader.cpp
|
||||
|
|
|
@ -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)
|
||||
|
|
17
Userland/Libraries/LibSoftGPU/ShaderCompiler.cpp
Normal file
17
Userland/Libraries/LibSoftGPU/ShaderCompiler.cpp
Normal 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, {}));
|
||||
}
|
||||
|
||||
}
|
21
Userland/Libraries/LibSoftGPU/ShaderCompiler.h
Normal file
21
Userland/Libraries/LibSoftGPU/ShaderCompiler.h
Normal 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&);
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue