Commit 353d1203 authored by Jean-Paul Saman's avatar Jean-Paul Saman

src/utils_glx.c: Avoid RGBA to BGRA conversion in software.

Speed up bitmap loading by avoiding conversions in software. The
GPU stores a bitmap internally in BGRA format instead of RGBA. By
using BGRA iso RGBA for format to load this conversion is ommitted
and a considerable speedup is obtained.
parent 932670e0
......@@ -796,7 +796,8 @@ gl_destroy_texture(
abort();
glEnable(target);
glDeleteTextures(1, texture);
if (glIsTexture(*texture))
glDeleteTextures(1, texture);
glDisable(target);
}
......@@ -855,6 +856,12 @@ gl_create_texture(
break;
case GL_RGBA:
case GL_BGRA:
/* NOTE: the GPU expects pixel data in BGRA format,
* otherwise it will do a conversion in software
* which is of course much slower then just copying
* the data into the GPU.
*/
format = GL_BGRA;
internal_format = GL_RGBA;
bytes_per_component = 4;
break;
......@@ -874,10 +881,13 @@ gl_create_texture(
glEnable(target);
glGenTextures(1, &texture);
if (gl_check_error())
abort();
glBindTexture(target, texture);
gl_set_texture_scaling(target, GL_LINEAR);
gl_set_texture_wrapping(target, GL_CLAMP_TO_EDGE);
glPixelStorei(GL_UNPACK_ALIGNMENT, bytes_per_component);
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
switch (target) {
case GL_TEXTURE_1D:
glTexImage1D(
......@@ -1209,6 +1219,7 @@ gl_destroy_shader_object(GLShaderObject *so)
gl_unbind_shader_object(so);
if (so->shader) {
gl_vtable->gl_delete_programs(1, &so->shader);
so->shader = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment