diff options
author | Stephan Unverwerth <s.unverwerth@serenityos.org> | 2022-09-17 17:52:34 +0200 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-17 22:39:09 -0700 |
commit | b18bf702eab3e3c08faffaac810ae1ac94bbc8fa (patch) | |
tree | 2048cbcf49d069af713a0857527629e171601060 /Userland/Libraries/LibSoftGPU/ShaderProcessor.h | |
parent | 1e548a84d69dcfba28ca705f2eb9889d0789836b (diff) | |
download | serenity-b18bf702eab3e3c08faffaac810ae1ac94bbc8fa.zip |
LibSoftGPU: Implement shader processor for SoftGPU ISA
This adds a shader processor that executes our ISA when a fragment
shader is currently bound to the device.
Diffstat (limited to 'Userland/Libraries/LibSoftGPU/ShaderProcessor.h')
-rw-r--r-- | Userland/Libraries/LibSoftGPU/ShaderProcessor.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Userland/Libraries/LibSoftGPU/ShaderProcessor.h b/Userland/Libraries/LibSoftGPU/ShaderProcessor.h new file mode 100644 index 0000000000..33bcc29f04 --- /dev/null +++ b/Userland/Libraries/LibSoftGPU/ShaderProcessor.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include <AK/Array.h> +#include <AK/SIMD.h> +#include <AK/Vector.h> +#include <LibGPU/Config.h> +#include <LibSoftGPU/PixelQuad.h> +#include <LibSoftGPU/Sampler.h> + +namespace SoftGPU { + +class Shader; + +class ShaderProcessor final { +public: + ShaderProcessor(Array<Sampler, GPU::NUM_TEXTURE_UNITS>& samplers) + : m_samplers { samplers } + { + } + + void execute(PixelQuad&, Shader const&); + + ALWAYS_INLINE AK::SIMD::f32x4 get_register(u16 index) const { return m_registers[index]; } + ALWAYS_INLINE void set_register(u16 index, AK::SIMD::f32x4 value) { m_registers[index] = value; } + +private: + void op_input(PixelQuad const&, Instruction::Arguments); + void op_output(PixelQuad&, Instruction::Arguments); + void op_sample2d(Instruction::Arguments); + void op_swizzle(Instruction::Arguments); + void op_add(Instruction::Arguments); + void op_sub(Instruction::Arguments); + void op_mul(Instruction::Arguments); + void op_div(Instruction::Arguments); + + Array<Sampler, GPU::NUM_TEXTURE_UNITS>& m_samplers; + AK::SIMD::f32x4 m_registers[1024]; +}; + +} |