mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +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:
parent
d7cfdfe633
commit
eb7c3d16fb
24 changed files with 1350 additions and 705 deletions
|
@ -169,3 +169,33 @@ TEST_CASE(0005_lines_antialiased)
|
|||
context->present();
|
||||
expect_bitmap_equals_reference(context->frontbuffer(), "0005_lines"sv);
|
||||
}
|
||||
|
||||
TEST_CASE(0006_test_rgb565_texture)
|
||||
{
|
||||
auto context = create_testing_context(64, 64);
|
||||
|
||||
GLuint texture_id;
|
||||
glGenTextures(1, &texture_id);
|
||||
glBindTexture(GL_TEXTURE_2D, texture_id);
|
||||
u16 texture_data[] = { 0xF800, 0xC000, 0x8000, 0x07E0, 0x0600, 0x0400, 0x001F, 0x0018, 0x0010 };
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 3, 3, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, texture_data);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2i(0, 0);
|
||||
glVertex2i(-1, 1);
|
||||
glTexCoord2i(0, 1);
|
||||
glVertex2i(-1, -1);
|
||||
glTexCoord2i(1, 1);
|
||||
glVertex2i(1, -1);
|
||||
glTexCoord2i(1, 0);
|
||||
glVertex2i(1, 1);
|
||||
glEnd();
|
||||
|
||||
EXPECT_EQ(glGetError(), 0u);
|
||||
|
||||
context->present();
|
||||
expect_bitmap_equals_reference(context->frontbuffer(), "0006_test_rgb565_texture"sv);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue