ShaderProcessor.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Array.h>
  8. #include <AK/SIMD.h>
  9. #include <AK/Vector.h>
  10. #include <LibGPU/Config.h>
  11. #include <LibSoftGPU/PixelQuad.h>
  12. #include <LibSoftGPU/Sampler.h>
  13. namespace SoftGPU {
  14. class Shader;
  15. class ShaderProcessor final {
  16. public:
  17. ShaderProcessor(Array<Sampler, GPU::NUM_TEXTURE_UNITS>& samplers)
  18. : m_samplers { samplers }
  19. {
  20. }
  21. void execute(PixelQuad&, Shader const&);
  22. ALWAYS_INLINE AK::SIMD::f32x4 get_register(u16 index) const { return m_registers[index]; }
  23. ALWAYS_INLINE void set_register(u16 index, AK::SIMD::f32x4 value) { m_registers[index] = value; }
  24. private:
  25. void op_input(PixelQuad const&, Instruction::Arguments);
  26. void op_output(PixelQuad&, Instruction::Arguments);
  27. void op_sample2d(Instruction::Arguments);
  28. void op_swizzle(Instruction::Arguments);
  29. void op_add(Instruction::Arguments);
  30. void op_sub(Instruction::Arguments);
  31. void op_mul(Instruction::Arguments);
  32. void op_div(Instruction::Arguments);
  33. Array<Sampler, GPU::NUM_TEXTURE_UNITS>& m_samplers;
  34. AK::SIMD::f32x4 m_registers[1024];
  35. };
  36. }