From: Stanislav Vorobiov Date: Fri, 21 Sep 2012 08:40:20 +0000 (+0400) Subject: YaGL: Fixed a memory bug in glGetBooleanv and glGetFloatv X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1405^2~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c2749042101d6461f26cb2c247adacfb5433fec;p=sdk%2Femulator%2Fqemu.git YaGL: Fixed a memory bug in glGetBooleanv and glGetFloatv YaGL: Fixed for Tizen 2.0 --- diff --git a/hw/yagl_apis/egl/yagl_host_egl_calls.c b/hw/yagl_apis/egl/yagl_host_egl_calls.c index 2e9fa4e3dd..7086af3fd4 100644 --- a/hw/yagl_apis/egl/yagl_host_egl_calls.c +++ b/hw/yagl_apis/egl/yagl_host_egl_calls.c @@ -1237,6 +1237,12 @@ EGLBoolean yagl_host_eglMakeCurrent(yagl_host_handle dpy_, yagl_egl_context_update_surfaces(prev_ctx, NULL, NULL); } + YAGL_LOG_TRACE("Context switched (%u, %u, %u, %u)", + dpy_, + draw_, + read_, + ctx_); + ret = EGL_TRUE; out: @@ -1480,7 +1486,82 @@ yagl_host_handle yagl_host_eglCreatePixmapSurfaceOffscreenYAGL(yagl_host_handle target_ulong /* void* */ pixels_, target_ulong /* const EGLint* */ attrib_list_) { - YAGL_UNIMPLEMENTED(eglCreatePixmapSurfaceOffscreenYAGL, 0); + yagl_host_handle ret = 0; + EGLint *attrib_list = NULL; + struct yagl_compiled_transfer *bimage_ct = NULL; + struct yagl_egl_pixmap_attribs attribs; + struct yagl_egl_display *dpy = NULL; + struct yagl_egl_config *config = NULL; + struct yagl_egl_surface *surface = NULL; + + YAGL_LOG_FUNC_SET_TS(egl_api_ts->ts, eglCreatePixmapSurfaceOffscreenYAGL); + + if (attrib_list_) { + attrib_list = yagl_mem_get_attrib_list(egl_api_ts->ts, + attrib_list_); + + if (!attrib_list) { + YAGL_SET_ERR(EGL_BAD_ATTRIBUTE); + goto out; + } + } + + bimage_ct = yagl_compiled_transfer_create(egl_api_ts->ts, + pixels_, + (width * height * bpp), + true); + + if (!bimage_ct) { + YAGL_SET_ERR(EGL_BAD_NATIVE_PIXMAP); + goto out; + } + + yagl_egl_pixmap_attribs_init(&attribs); + + if (!yagl_egl_is_attrib_list_empty(attrib_list)) { + YAGL_SET_ERR(EGL_BAD_ATTRIBUTE); + goto out; + } + + if (!yagl_validate_display(dpy_, &dpy)) { + goto out; + } + + if (!yagl_validate_config(dpy, config_, &config)) { + goto out; + } + + surface = yagl_egl_surface_create_pixmap(dpy, + config, + &attribs, + bimage_ct, + width, + height, + bpp); + + if (!surface) { + YAGL_SET_ERR(EGL_BAD_ALLOC); + goto out; + } + + /* + * Owned by 'surface' now. + */ + bimage_ct = NULL; + + yagl_egl_display_add_surface(dpy, surface); + yagl_egl_surface_release(surface); + + ret = surface->res.handle; + +out: + yagl_egl_config_release(config); + if (bimage_ct) { + yagl_compiled_transfer_destroy(bimage_ct); + } + g_free(attrib_list); + + return ret; } EGLBoolean yagl_host_eglResizeOffscreenSurfaceYAGL(yagl_host_handle dpy_, diff --git a/hw/yagl_apis/gles/yagl_host_gles_calls.c b/hw/yagl_apis/gles/yagl_host_gles_calls.c index edb6e3808b..421a0f9238 100644 --- a/hw/yagl_apis/gles/yagl_host_gles_calls.c +++ b/hw/yagl_apis/gles/yagl_host_gles_calls.c @@ -861,6 +861,7 @@ void yagl_host_glGetBooleanv(GLenum pname, YAGL_GET_CTX(glGetBooleanv); if (!ctx->get_param_count(ctx, pname, &count)) { + YAGL_LOG_ERROR("Bad pname = 0x%X", pname); YAGL_SET_ERR(GL_INVALID_ENUM); goto out; } @@ -879,9 +880,9 @@ void yagl_host_glGetBooleanv(GLenum pname, if (params_) { for (i = 0; i < count; ++i) { - yagl_mem_put_GLuint(ts, - params_ + (i * sizeof(*params)), - params[i]); + yagl_mem_put_GLboolean(ts, + params_ + (i * sizeof(*params)), + params[i]); } } @@ -920,6 +921,7 @@ void yagl_host_glGetFloatv(GLenum pname, YAGL_GET_CTX(glGetFloatv); if (!ctx->get_param_count(ctx, pname, &count)) { + YAGL_LOG_ERROR("Bad pname = 0x%X", pname); YAGL_SET_ERR(GL_INVALID_ENUM); goto out; } @@ -938,9 +940,9 @@ void yagl_host_glGetFloatv(GLenum pname, if (params_) { for (i = 0; i < count; ++i) { - yagl_mem_put_GLuint(ts, - params_ + (i * sizeof(*params)), - params[i]); + yagl_mem_put_GLfloat(ts, + params_ + (i * sizeof(*params)), + params[i]); } } @@ -957,6 +959,7 @@ void yagl_host_glGetIntegerv(GLenum pname, YAGL_GET_CTX(glGetIntegerv); if (!ctx->get_param_count(ctx, pname, &count)) { + YAGL_LOG_ERROR("Bad pname = 0x%X", pname); YAGL_SET_ERR(GL_INVALID_ENUM); goto out; } @@ -1048,9 +1051,54 @@ void yagl_host_glReadPixels(GLint x, GLsizei height, GLenum format, GLenum type, - target_ulong /* GLvoid* */ pixels) + target_ulong /* GLvoid* */ pixels_) { - YAGL_UNIMPLEMENTED(glReadPixels); + yagl_object_name current_pbo = 0; + GLvoid *pixels = NULL; + GLsizei stride = 0; + + YAGL_GET_CTX(glReadPixels); + + if (pixels_ && (width > 0) && (height > 0)) { + if (!yagl_get_stride(ctx->driver_ps, + GL_PACK_ALIGNMENT, + width, + format, + type, + &stride)) { + YAGL_SET_ERR(GL_INVALID_VALUE); + goto out; + } + pixels = yagl_gles_context_malloc(ctx, stride * height); + ctx->driver_ps->GetIntegerv(ctx->driver_ps, + GL_PIXEL_PACK_BUFFER_BINDING_ARB, + (GLint*)¤t_pbo); + if (current_pbo != 0) { + ctx->driver_ps->BindBuffer(ctx->driver_ps, + GL_PIXEL_PACK_BUFFER_ARB, + 0); + } + + ctx->driver_ps->ReadPixels(ctx->driver_ps, + x, + y, + width, + height, + format, + type, + pixels); + + if (current_pbo != 0) { + ctx->driver_ps->BindBuffer(ctx->driver_ps, + GL_PIXEL_PACK_BUFFER_ARB, + current_pbo); + } + + yagl_mem_put(ts, pixels_, stride * height, pixels); + } + +out: + (void)0; } void yagl_host_glSampleCoverage(GLclampf value, diff --git a/hw/yagl_apis/gles/yagl_host_gles_calls.h b/hw/yagl_apis/gles/yagl_host_gles_calls.h index 148d16a895..95ac2f74fd 100644 --- a/hw/yagl_apis/gles/yagl_host_gles_calls.h +++ b/hw/yagl_apis/gles/yagl_host_gles_calls.h @@ -119,7 +119,7 @@ void yagl_host_glReadPixels(GLint x, GLsizei height, GLenum format, GLenum type, - target_ulong /* GLvoid* */ pixels); + target_ulong /* GLvoid* */ pixels_); void yagl_host_glSampleCoverage(GLclampf value, GLboolean invert); void yagl_host_glScissor(GLint x, diff --git a/hw/yagl_apis/gles2/yagl_gles2_context.c b/hw/yagl_apis/gles2/yagl_gles2_context.c index 5ba0084257..ec8835c53c 100644 --- a/hw/yagl_apis/gles2/yagl_gles2_context.c +++ b/hw/yagl_apis/gles2/yagl_gles2_context.c @@ -6,6 +6,7 @@ #include "yagl_thread.h" #include "yagl_sharegroup.h" #include +#include #include "yagl_gles2_driver.h" static void yagl_gles2_array_apply(struct yagl_gles_array *array) @@ -137,6 +138,7 @@ static bool yagl_gles2_context_get_param_count(struct yagl_gles_context *ctx, case GL_TEXTURE_BINDING_CUBE_MAP: *count = 1; break; case GL_UNPACK_ALIGNMENT: *count = 1; break; case GL_VIEWPORT: *count = 4; break; + case GL_MAX_SAMPLES_IMG: *count = 1; break; default: return false; } return true; diff --git a/hw/yagl_mem_gl.h b/hw/yagl_mem_gl.h index 1be3a023f3..1ffc97cc37 100644 --- a/hw/yagl_mem_gl.h +++ b/hw/yagl_mem_gl.h @@ -11,5 +11,9 @@ #define yagl_mem_get_GLsizei(ts, va, value) yagl_mem_get_int32((ts), (va), (value)) #define yagl_mem_put_GLenum(ts, va, value) yagl_mem_put_uint32((ts), (va), (value)) #define yagl_mem_get_GLenum(ts, va, value) yagl_mem_get_uint32((ts), (va), (value)) +#define yagl_mem_put_GLfloat(ts, va, value) yagl_mem_put_float((ts), (va), (value)) +#define yagl_mem_get_GLfloat(ts, va, value) yagl_mem_get_float((ts), (va), (value)) +#define yagl_mem_put_GLboolean(ts, va, value) yagl_mem_put_uint8((ts), (va), (value)) +#define yagl_mem_get_GLboolean(ts, va, value) yagl_mem_get_uint8((ts), (va), (value)) #endif diff --git a/hw/yagl_version.h b/hw/yagl_version.h index 6ba7f3cb3c..166ecfcd1e 100644 --- a/hw/yagl_version.h +++ b/hw/yagl_version.h @@ -6,6 +6,6 @@ /* * Whenever protocol changes be sure to bump this. */ -#define YAGL_VERSION 5 +#define YAGL_VERSION 6 #endif