opengl - Mipmaps+PBO: strange issues -
i'm using pbos load textures faster in application. if use opengl 3 or better video card can build mipmaps call glgeneratemipmap , works fine. on older opengl 2.1 card (radeon x800), function not available must use 1 of 2 legacy methods:
gltexparameteri(gl_texture_2d, gl_generate_mipmap, gl_true); glteximage2d(gl_texture_2d, 0, gl_rgba8, w,h, 0,gl_rgba,gl_unsigned_byte, src);    or
glubuild2dmipmaps(gl_texture_2d, gl_rgba8, w,h, gl_rgba,gl_unsigned_byte, src);   the first method doesn't work fine whitout pbo, introduces strange artifacts. second one, whitout pbo builds correct mipmaps, , pbo generates segfault. can help??
for completeness attach code use pbo:
uint pixelbuffer; glgenbuffers(1, &pixelbuffer); glbindbuffer(gl_pixel_unpack_buffer, pixelbuffer); glbufferdata(gl_pixel_unpack_buffer, size*4, null, gl_static_read); char *pixels = (char*)glmapbuffer(gl_pixel_unpack_buffer, gl_write_only); ... transfer data glunmapbuffer(gl_pixel_unpack_buffer); ... , use buffer create texture   ps if don't try generate mipmaps, pbo loading works on video cards.
this simple, glubuild2dmipmaps() expects pointer in client memory (because glu function, not part of driver) not work pbo. using the
gltexparameteri(gl_texture_2d, gl_generate_mipmap, gl_true);
try calling after glteximage2d(). drivers implement extension differently , require line called everytime when mipmaps should generated (there's nothing done "automatic aly"). strange artifacts random data in higher mipmap levels because mipmaps weren't generated @ all.
as using pbo speed, legit method. there might new way possible "pinned memory", haven't looked yet.
Comments
Post a Comment