From eb4fe88d9633d17c9ac454fa1abdaa338f73adce Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 2 Mar 2013 14:29:22 +0100 Subject: [PATCH] (PS3) Usage of glMapBuffer + texture references (while slightly faster) appeared to produce garbage in frames. Possible PSGL bug. Revert to glBufferSubData approach for now --- gfx/gl.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/gfx/gl.c b/gfx/gl.c index 4748f12c53..9a0bc92e53 100644 --- a/gfx/gl.c +++ b/gfx/gl.c @@ -1045,16 +1045,25 @@ static void gl_init_textures_data(void *data) static inline void gl_copy_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch) { gl_t *gl = (gl_t*)data; + + if (!gl->fbo_inited) + gl_set_viewport(gl, gl->win_width, gl->win_height, false, true); + size_t buffer_addr = gl->tex_w * gl->tex_h * gl->tex_index * gl->base_size; size_t buffer_stride = gl->tex_w * gl->base_size; const uint8_t *frame_copy = frame; size_t frame_copy_size = width * gl->base_size; - uint8_t *buffer = (uint8_t*)glMapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE, GL_WRITE_ONLY) + buffer_addr; - for (unsigned h = 0; h < height; h++, buffer += buffer_stride, frame_copy += pitch) - memcpy(buffer, frame_copy, frame_copy_size); + for (unsigned h = 0; h < height; h++) + { + glBufferSubData(GL_TEXTURE_REFERENCE_BUFFER_SCE, + buffer_addr, + frame_copy_size, + frame_copy); - glUnmapBuffer(GL_TEXTURE_REFERENCE_BUFFER_SCE); + frame_copy += pitch; + buffer_addr += buffer_stride; + } } static void gl_init_textures(void *data, const video_info_t *video)