ladybird/Userland/Libraries/LibSoftGPU/PixelConverter.h
Jelle Raaijmakers 84c4b66721 LibGL+LibGPU+LibSoftGPU: Implement texture pixel format support
In OpenGL this is called the (base) internal format which is an
expectation expressed by the client for the minimum supported texel
storage format in the GPU for textures.

Since we store everything as RGBA in a `FloatVector4`, the only thing
we do in this patch is remember the expected internal format, and when
we write new texels we fixate the value for the alpha channel to 1 for
two formats that require it.

`PixelConverter` has learned how to transform pixels during transfer to
support this.
2022-08-27 12:28:05 +02:00

35 lines
833 B
C++

/*
* Copyright (c) 2022, Jelle Raaijmakers <jelle@gmta.nl>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Error.h>
#include <AK/Function.h>
#include <LibGPU/ImageDataLayout.h>
#include <LibGfx/Vector4.h>
namespace SoftGPU {
class PixelConverter {
public:
PixelConverter(GPU::ImageDataLayout input_specification, GPU::ImageDataLayout output_specification)
: m_input_specification { input_specification }
, m_output_specification { output_specification }
{
}
ErrorOr<void> convert(void const* input_data, void* output_data, Function<void(FloatVector4&)> transform);
private:
FloatVector4 read_pixel(u8 const**);
void write_pixel(u8**, FloatVector4 const&);
GPU::ImageDataLayout m_input_specification;
GPU::ImageDataLayout m_output_specification;
};
}