1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:37:34 +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

@ -21,9 +21,9 @@ public:
virtual ~Image() { }
virtual void write_texels(unsigned layer, unsigned level, Vector3<unsigned> const& offset, Vector3<unsigned> const& size, void const* data, ImageDataLayout const& layout) = 0;
virtual void read_texels(unsigned layer, unsigned level, Vector3<unsigned> const& offset, Vector3<unsigned> const& size, void* data, ImageDataLayout const& layout) const = 0;
virtual void copy_texels(Image const& source, unsigned source_layer, unsigned source_level, Vector3<unsigned> const& source_offset, Vector3<unsigned> const& size, unsigned destination_layer, unsigned destination_level, Vector3<unsigned> const& destination_offset) = 0;
virtual void write_texels(u32 layer, u32 level, Vector3<i32> const& output_offset, void const* data, ImageDataLayout const&) = 0;
virtual void read_texels(u32 layer, u32 level, Vector3<i32> const& input_offset, void* data, ImageDataLayout const&) const = 0;
virtual void copy_texels(Image const& source, u32 source_layer, u32 source_level, Vector3<u32> const& source_offset, Vector3<u32> const& size, u32 destination_layer, u32 destination_level, Vector3<u32> const& destination_offset) = 0;
void const* ownership_token() const { return m_ownership_token; }
bool has_same_ownership_token(Image const& other) const { return other.ownership_token() == ownership_token(); }