mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +00:00
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.
This commit is contained in:
parent
6c80d12111
commit
84c4b66721
13 changed files with 141 additions and 32 deletions
|
@ -359,7 +359,7 @@ static constexpr GPU::ImageSelection restrain_selection_within_dimensions(GPU::I
|
|||
return selection;
|
||||
}
|
||||
|
||||
ErrorOr<void> PixelConverter::convert(void const* input_data, void* output_data)
|
||||
ErrorOr<void> PixelConverter::convert(void const* input_data, void* output_data, Function<void(FloatVector4&)> transform)
|
||||
{
|
||||
// Verify pixel data specifications
|
||||
auto validate_image_data_layout = [](GPU::ImageDataLayout const& specification) -> ErrorOr<void> {
|
||||
|
@ -428,6 +428,8 @@ ErrorOr<void> PixelConverter::convert(void const* input_data, void* output_data)
|
|||
+ output_selection.offset_x * output_pixel_size_in_bytes];
|
||||
for (u32 input_x = input_selection.offset_x; input_x < input_selection.offset_x + input_selection.width; ++input_x) {
|
||||
auto pixel_components = read_pixel(&input_scanline);
|
||||
if (transform)
|
||||
transform(pixel_components);
|
||||
write_pixel(&output_scanline, pixel_components);
|
||||
}
|
||||
++output_y;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue