1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:37:36 +00:00

LibGL+LibGPU+LibSoftGPU: Implement flexible pixel format conversion

A GPU (driver) is now responsible for reading and writing pixels from
and to user data. The client (LibGL) is responsible for specifying how
the user data must be interpreted or written to.

This allows us to centralize all pixel format conversion in one class,
`LibSoftGPU::PixelConverter`. For both the input and output image, it
takes a specification containing the image dimensions, the pixel type
and the selection (basically a clipping rect), and converts the pixels
from the input image to the output image.

Effectively this means we now support almost all OpenGL 1.5 formats,
and all custom logic has disappeared from:
  - `glDrawPixels`
  - `glReadPixels`
  - `glTexImage2D`
  - `glTexSubImage2D`

The new logic is still unoptimized, but on my machine I experienced no
noticeable slowdown. :^)
This commit is contained in:
Jelle Raaijmakers 2022-08-24 23:47:49 +02:00 committed by Andreas Kling
parent d7cfdfe633
commit eb7c3d16fb
24 changed files with 1350 additions and 705 deletions

View file

@ -52,17 +52,17 @@ public:
virtual void clear_color(FloatVector4 const&) override;
virtual void clear_depth(GPU::DepthType) override;
virtual void clear_stencil(GPU::StencilType) override;
virtual void blit_from_color_buffer(void*, Vector2<i32> offset, GPU::ImageDataLayout const&) override;
virtual void blit_from_depth_buffer(void*, Vector2<i32> offset, GPU::ImageDataLayout const&) override;
virtual void blit_color_buffer_to(Gfx::Bitmap& target) override;
virtual void blit_to_color_buffer_at_raster_position(Gfx::Bitmap const&) override;
virtual void blit_to_depth_buffer_at_raster_position(Vector<GPU::DepthType> const&, int, int) override;
virtual void blit_to_color_buffer_at_raster_position(void const*, GPU::ImageDataLayout const&) override;
virtual void blit_to_depth_buffer_at_raster_position(void const*, GPU::ImageDataLayout const&) override;
virtual void set_options(GPU::RasterizerOptions const&) override;
virtual void set_light_model_params(GPU::LightModelParameters const&) override;
virtual GPU::RasterizerOptions options() const override { return m_options; }
virtual GPU::LightModelParameters light_model() const override { return m_lighting_model; }
virtual GPU::ColorType get_color_buffer_pixel(int x, int y) override;
virtual GPU::DepthType get_depthbuffer_value(int x, int y) override;
virtual NonnullRefPtr<GPU::Image> create_image(GPU::ImageFormat format, unsigned width, unsigned height, unsigned depth, unsigned levels, unsigned layers) override;
virtual NonnullRefPtr<GPU::Image> create_image(GPU::PixelType const&, u32 width, u32 height, u32 depth, u32 levels, u32 layers) override;
virtual void set_sampler_config(unsigned, GPU::SamplerConfig const&) override;
virtual void set_light_state(unsigned, GPU::Light const&) override;
@ -79,6 +79,9 @@ private:
void draw_statistics_overlay(Gfx::Bitmap&);
Gfx::IntRect get_rasterization_rect_of_size(Gfx::IntSize size) const;
GPU::ImageDataLayout color_buffer_data_layout(Vector2<u32> size, Vector2<i32> offset);
GPU::ImageDataLayout depth_buffer_data_layout(Vector2<u32> size, Vector2<i32> offset);
template<typename CB1, typename CB2, typename CB3>
void rasterize(Gfx::IntRect& render_bounds, CB1 set_coverage_mask, CB2 set_quad_depth, CB3 set_quad_attributes);