`ALLEGRO_BITMAP_WRAP` settings are not necessarily respected
Opened this issue · 2 comments
I wrote a fragment shader in which I read neighboring pixels for a post-processing effect. I expect the texture reads to follow the wrapping settings set with al_set_new_bitmap_wrap()
. However, that won't happen as expected when the internal texture allocated by Allegro is larger than the ALLEGRO_BITMAP
.
Here is an example of my shader running on Android. Notice the yellow artifacts at the right edge of the screen.
- My shader takes as input a texture of a partially rendered scene (I render to an offscreen texture).
- The size of the input bitmap is 426x240. I clear it with
al_clear_to_color(yellow)
- for testing - before it receives the partially rendered scene. The scene covers the entire bitmap. - I set
ALLEGRO_SUPPORT_NPOT_BITMAP
to 1 before creating the display. al_get_opengl_texture_size()
tells me that the OpenGL texture size is 448x240 on Android (GLES3). I looked into the source code and found that this size is consistent with the following logic: (I can't turn it off)allegro5/src/opengl/ogl_bitmap.c
Lines 1079 to 1085 in e3ad047
- These artifacts do not appear when using OpenGL on a Linux desktop. Texture size is 426x240, as expected.
shader_wrap_demo.mp4
I feel we should just remove that workaround (and probably the minimum-size one above as well?). And in the future if we want hacks like that we should do it for just the specific GPU that needs it (and with a much more detailed comment why exactly it's needed).
We already have a allegro5.cfg setting for minimum bitmap size. We could also add one for this to disable it. Could call it 'android_bitmap_size_align = 32'