diff options
author | Stephan Unverwerth <s.unverwerth@serenityos.org> | 2022-09-16 18:50:07 +0200 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-12-17 22:39:09 -0700 |
commit | 49139d5f4ebc72faf416090fa4ee898b2a09878f (patch) | |
tree | 5d1cc2d0e87c882e661705394a41b3e4acd6e5a1 /Userland/Libraries/LibSoftGPU | |
parent | 93ab2db80fed38b6e621085b5e060ae726d77a88 (diff) | |
download | serenity-49139d5f4ebc72faf416090fa4ee898b2a09878f.zip |
LibSoftGPU: Allow binding a fragment shader
Diffstat (limited to 'Userland/Libraries/LibSoftGPU')
-rw-r--r-- | Userland/Libraries/LibSoftGPU/Device.cpp | 13 | ||||
-rw-r--r-- | Userland/Libraries/LibSoftGPU/Device.h | 4 |
2 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Libraries/LibSoftGPU/Device.cpp b/Userland/Libraries/LibSoftGPU/Device.cpp index 318617d7e6..87108c05a7 100644 --- a/Userland/Libraries/LibSoftGPU/Device.cpp +++ b/Userland/Libraries/LibSoftGPU/Device.cpp @@ -1700,6 +1700,19 @@ void Device::set_raster_position(FloatVector4 const& position, FloatMatrix4x4 co m_raster_position.eye_coordinate_distance = eye_coordinates.length(); } +void Device::bind_fragment_shader(RefPtr<GPU::Shader> shader) +{ + VERIFY(shader.is_null() || shader->ownership_token() == this); + + if (shader.is_null()) { + m_current_fragment_shader = nullptr; + return; + } + + auto softgpu_shader = static_ptr_cast<Shader>(shader); + m_current_fragment_shader = softgpu_shader; +} + Gfx::IntRect Device::get_rasterization_rect_of_size(Gfx::IntSize size) const { // Round the X and Y floating point coordinates to the nearest integer; OpenGL 1.5 spec: diff --git a/Userland/Libraries/LibSoftGPU/Device.h b/Userland/Libraries/LibSoftGPU/Device.h index 027a81d081..a7660b0154 100644 --- a/Userland/Libraries/LibSoftGPU/Device.h +++ b/Userland/Libraries/LibSoftGPU/Device.h @@ -35,6 +35,7 @@ #include <LibSoftGPU/Clipper.h> #include <LibSoftGPU/Config.h> #include <LibSoftGPU/Sampler.h> +#include <LibSoftGPU/Shader.h> #include <LibSoftGPU/Triangle.h> namespace SoftGPU { @@ -78,6 +79,8 @@ public: virtual void set_raster_position(GPU::RasterPosition const& raster_position) override; virtual void set_raster_position(FloatVector4 const& position, FloatMatrix4x4 const& model_view_transform, FloatMatrix4x4 const& projection_transform) override; + virtual void bind_fragment_shader(RefPtr<GPU::Shader>) override; + private: void calculate_vertex_lighting(GPU::Vertex& vertex) const; void draw_statistics_overlay(Gfx::Bitmap&); @@ -116,6 +119,7 @@ private: Vector<FloatVector4> m_clip_planes; Array<GPU::StencilConfiguration, 2u> m_stencil_configuration; Array<GPU::TextureUnitConfiguration, GPU::NUM_TEXTURE_UNITS> m_texture_unit_configuration; + RefPtr<Shader> m_current_fragment_shader; }; } |