diff options
author | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2014-01-21 12:00:13 +0400 |
---|---|---|
committer | Stanislav Vorobiov <s.vorobiov@samsung.com> | 2014-01-21 12:00:13 +0400 |
commit | 27e361414d875f6284c92ec9d86e4320dc859261 (patch) | |
tree | ce54cfcb80d41ed9dec472bdc3bc64b768dad432 /GLESv2 | |
parent | fc0164419689bda8699eabafe6aa4339ab507158 (diff) | |
download | emulator-yagl-27e361414d875f6284c92ec9d86e4320dc859261.tar.gz emulator-yagl-27e361414d875f6284c92ec9d86e4320dc859261.tar.bz2 emulator-yagl-27e361414d875f6284c92ec9d86e4320dc859261.zip |
YaGL: Basic GL_NV_pixel_buffer_object support
Automatic PBO transfers between host and guest not
implemented yet
Change-Id: I48e171983ff7c8b4be2adaf6a1d70952e6e8075b
Diffstat (limited to 'GLESv2')
-rw-r--r-- | GLESv2/yagl_gles2_calls.c | 191 | ||||
-rw-r--r-- | GLESv2/yagl_gles2_context.c | 46 | ||||
-rw-r--r-- | GLESv2/yagl_gles3_context.c | 14 | ||||
-rw-r--r-- | GLESv2/yagl_texcompress.c | 4 |
4 files changed, 160 insertions, 95 deletions
diff --git a/GLESv2/yagl_gles2_calls.c b/GLESv2/yagl_gles2_calls.c index d415adf..de1dfac 100644 --- a/GLESv2/yagl_gles2_calls.c +++ b/GLESv2/yagl_gles2_calls.c @@ -2088,7 +2088,9 @@ YAGL_API YAGL_ALIAS(glVertexAttribDivisor, glVertexAttribDivisorEXT); YAGL_API void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels) { yagl_gles_texture_target texture_target; - GLsizei stride = 0; + GLsizei stride; + int need_convert; + int using_pbo = 0; YAGL_LOG_FUNC_ENTER_SPLIT10(glTexImage3D, GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const void*, target, level, internalformat, width, height, depth, border, format, type, pixels); @@ -2106,35 +2108,65 @@ YAGL_API void glTexImage3D(GLenum target, GLint level, GLint internalformat, GLs goto out; } - if (pixels && (width > 0) && (height > 0) && (depth > 0)) { - if (!yagl_gles_context_get_stride(&ctx->base, - ctx->base.unpack_alignment, - width, - format, - type, - &stride)) { - YAGL_SET_ERR(GL_INVALID_OPERATION); - goto out; - } + if ((width < 0) || (height < 0) || (depth < 0)) { + YAGL_SET_ERR(GL_INVALID_VALUE); + goto out; } - yagl_host_glTexImage3D(target, - level, - yagl_gles_get_actual_internalformat(internalformat), - width, - height, - depth, - border, - yagl_gles_get_actual_format(format), - yagl_gles_get_actual_type(type), - yagl_gles_convert_to_host(ctx->base.unpack_alignment, - width, - height, - depth, - format, - type, - pixels), - stride * height * depth); + if ((width == 0) || (height == 0) || (depth == 0)) { + width = height = depth = 0; + } + + if (!yagl_gles_context_get_stride(&ctx->base, + ctx->base.unpack.alignment, + width, + format, + type, + &stride, + &need_convert)) { + YAGL_SET_ERR(GL_INVALID_OPERATION); + goto out; + } + + if ((width != 0) && !yagl_gles_context_pre_unpack(&ctx->base, &pixels, need_convert, &using_pbo)) { + YAGL_SET_ERR(GL_INVALID_OPERATION); + goto out; + } + + if (using_pbo) { + yagl_host_glTexImage3DOffset(target, + level, + yagl_gles_get_actual_internalformat(internalformat), + width, + height, + depth, + border, + yagl_gles_get_actual_format(format), + yagl_gles_get_actual_type(type), + (GLsizei)pixels); + } else { + yagl_host_glTexImage3DData(target, + level, + yagl_gles_get_actual_internalformat(internalformat), + width, + height, + depth, + border, + yagl_gles_get_actual_format(format), + yagl_gles_get_actual_type(type), + yagl_gles_convert_to_host(ctx->base.unpack.alignment, + width, + height, + depth, + format, + type, + pixels), + stride * height * depth); + } + + if (width != 0) { + yagl_gles_context_post_unpack(&ctx->base, need_convert); + } out: YAGL_LOG_FUNC_EXIT(NULL); @@ -2144,7 +2176,9 @@ YAGL_API YAGL_ALIAS(glTexImage3D, glTexImage3DOES); YAGL_API void glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels) { yagl_gles_texture_target texture_target; - GLsizei stride = 0; + GLsizei stride; + int need_convert; + int using_pbo = 0; YAGL_LOG_FUNC_ENTER_SPLIT11(glTexSubImage3D, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const void*, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels); @@ -2162,36 +2196,67 @@ YAGL_API void glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint y goto out; } - if (pixels && (width > 0) && (height > 0) && (depth > 0)) { - if (!yagl_gles_context_get_stride(&ctx->base, - ctx->base.unpack_alignment, - width, - format, - type, - &stride)) { - YAGL_SET_ERR(GL_INVALID_OPERATION); - goto out; - } + if ((width < 0) || (height < 0) || (depth < 0)) { + YAGL_SET_ERR(GL_INVALID_VALUE); + goto out; } - yagl_host_glTexSubImage3D(target, - level, - xoffset, - yoffset, - zoffset, - width, - height, - depth, - yagl_gles_get_actual_format(format), - yagl_gles_get_actual_type(type), - yagl_gles_convert_to_host(ctx->base.unpack_alignment, - width, - height, - depth, - format, - type, - pixels), - stride * height * depth); + if ((width == 0) || (height == 0) || (depth == 0)) { + width = height = depth = 0; + } + + if (!yagl_gles_context_get_stride(&ctx->base, + ctx->base.unpack.alignment, + width, + format, + type, + &stride, + &need_convert)) { + YAGL_SET_ERR(GL_INVALID_OPERATION); + goto out; + } + + if ((width != 0) && !yagl_gles_context_pre_unpack(&ctx->base, &pixels, need_convert, &using_pbo)) { + YAGL_SET_ERR(GL_INVALID_OPERATION); + goto out; + } + + if (using_pbo) { + yagl_host_glTexSubImage3DOffset(target, + level, + xoffset, + yoffset, + zoffset, + width, + height, + depth, + yagl_gles_get_actual_format(format), + yagl_gles_get_actual_type(type), + (GLsizei)pixels); + } else { + yagl_host_glTexSubImage3DData(target, + level, + xoffset, + yoffset, + zoffset, + width, + height, + depth, + yagl_gles_get_actual_format(format), + yagl_gles_get_actual_type(type), + yagl_gles_convert_to_host(ctx->base.unpack.alignment, + width, + height, + depth, + format, + type, + pixels), + stride * height * depth); + } + + if (width != 0) { + yagl_gles_context_post_unpack(&ctx->base, need_convert); + } out: YAGL_LOG_FUNC_EXIT(NULL); @@ -2316,9 +2381,9 @@ YAGL_API void glTexStorage3D(GLenum target, GLsizei levels, GLenum internalforma switch (texture_target) { case yagl_gles_texture_target_3d: for (i = 0; i < levels; ++i) { - yagl_host_glTexImage3D(target, i, internalformat, - width, height, depth, 0, format, type, - NULL, 0); + yagl_host_glTexImage3DData(target, i, internalformat, + width, height, depth, 0, format, type, + NULL, 0); width >>= 1; if (width == 0) { @@ -2338,9 +2403,9 @@ YAGL_API void glTexStorage3D(GLenum target, GLsizei levels, GLenum internalforma break; case yagl_gles_texture_target_2d_array: for (i = 0; i < levels; ++i) { - yagl_host_glTexImage3D(target, i, internalformat, - width, height, depth, 0, format, type, - NULL, 0); + yagl_host_glTexImage3DData(target, i, internalformat, + width, height, depth, 0, format, type, + NULL, 0); width >>= 1; if (width == 0) { diff --git a/GLESv2/yagl_gles2_context.c b/GLESv2/yagl_gles2_context.c index 9a3ea0b..3f0a01a 100644 --- a/GLESv2/yagl_gles2_context.c +++ b/GLESv2/yagl_gles2_context.c @@ -44,6 +44,7 @@ static const GLchar *element_index_uint_ext = "GL_OES_element_index_uint"; static const GLchar *texture_3d_ext = "GL_OES_texture_3D"; static const GLchar *blend_minmax_ext = "GL_EXT_blend_minmax"; static const GLchar *texture_storage_ext = "GL_EXT_texture_storage"; +static const GLchar *pbo_ext = "GL_NV_pixel_buffer_object"; static const GLchar *packed_depth_stencil_ext = "GL_OES_packed_depth_stencil"; static const GLchar *texture_npot_ext = "GL_OES_texture_npot"; static const GLchar *texture_rectangle_ext = "GL_ARB_texture_rectangle"; @@ -78,6 +79,7 @@ static const GLchar **yagl_gles2_context_get_extensions(struct yagl_gles2_contex extensions[i++] = texture_3d_ext; extensions[i++] = blend_minmax_ext; extensions[i++] = texture_storage_ext; + extensions[i++] = pbo_ext; if (ctx->base.packed_depth_stencil) { extensions[i++] = packed_depth_stencil_ext; @@ -408,22 +410,22 @@ void yagl_gles2_context_compressed_tex_image(struct yagl_gles_context *gles_ctx, buff, dst_stride); - saved_alignment = gles_ctx->unpack_alignment; + saved_alignment = gles_ctx->unpack.alignment; if (saved_alignment != 1) { yagl_host_glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } - yagl_host_glTexImage2D(target, - level, - tc_format->dst_internalformat, - width, - height, - border, - tc_format->dst_format, - tc_format->dst_type, - buff, - dst_size); + yagl_host_glTexImage2DData(target, + level, + tc_format->dst_internalformat, + width, + height, + border, + tc_format->dst_format, + tc_format->dst_type, + buff, + dst_size); if (saved_alignment != 1) { yagl_host_glPixelStorei(GL_UNPACK_ALIGNMENT, saved_alignment); @@ -479,22 +481,22 @@ void yagl_gles2_context_compressed_tex_sub_image(struct yagl_gles_context *gles_ buff, dst_stride); - saved_alignment = gles_ctx->unpack_alignment; + saved_alignment = gles_ctx->unpack.alignment; if (saved_alignment != 1) { yagl_host_glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } - yagl_host_glTexSubImage2D(target, - level, - xoffset, - yoffset, - width, - height, - tc_format->dst_format, - tc_format->dst_type, - buff, - dst_size); + yagl_host_glTexSubImage2DData(target, + level, + xoffset, + yoffset, + width, + height, + tc_format->dst_format, + tc_format->dst_type, + buff, + dst_size); if (saved_alignment != 1) { yagl_host_glPixelStorei(GL_UNPACK_ALIGNMENT, saved_alignment); diff --git a/GLESv2/yagl_gles3_context.c b/GLESv2/yagl_gles3_context.c index 6c90ef5..222d1c9 100644 --- a/GLESv2/yagl_gles3_context.c +++ b/GLESv2/yagl_gles3_context.c @@ -6,6 +6,7 @@ #include "yagl_gles2_utils.h" #include "yagl_gles_buffer.h" #include "yagl_gles_texture_unit.h" +#include "yagl_gles_texture.h" #include "yagl_gles_sampler.h" #include "yagl_log.h" #include "yagl_malloc.h" @@ -271,6 +272,7 @@ static int yagl_gles3_context_get_integerv(struct yagl_gles_context *ctx, int processed = 1; struct yagl_gles3_context *gles3_ctx = (struct yagl_gles3_context*)ctx; struct yagl_gles_sampler *sampler; + struct yagl_gles_texture_target_state *tts; switch (pname) { case GL_MAX_UNIFORM_BUFFER_BINDINGS: @@ -314,6 +316,12 @@ static int yagl_gles3_context_get_integerv(struct yagl_gles_context *ctx, *params = sampler ? sampler->base.local_name : 0; *num_params = 1; break; + case GL_TEXTURE_BINDING_2D_ARRAY: + tts = yagl_gles_context_get_active_texture_target_state(ctx, + yagl_gles_texture_target_2d_array); + *params = tts->texture ? tts->texture->base.local_name : 0; + *num_params = 1; + break; default: processed = 0; break; @@ -328,7 +336,6 @@ static int yagl_gles3_context_get_integerv(struct yagl_gles_context *ctx, case GL_COPY_WRITE_BUFFER_BINDING: case GL_FRAGMENT_SHADER_DERIVATIVE_HINT: case GL_MAJOR_VERSION: - case GL_MAX_3D_TEXTURE_SIZE: case GL_MAX_ARRAY_TEXTURE_LAYERS: case GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS: case GL_MAX_COMBINED_UNIFORM_BLOCKS: @@ -358,13 +365,8 @@ static int yagl_gles3_context_get_integerv(struct yagl_gles_context *ctx, case GL_PACK_SKIP_IMAGES: case GL_PACK_SKIP_PIXELS: case GL_PACK_SKIP_ROWS: - case GL_PIXEL_PACK_BUFFER_BINDING: - case GL_PIXEL_UNPACK_BUFFER_BINDING: case GL_PRIMITIVE_RESTART_FIXED_INDEX: case GL_READ_BUFFER: - case GL_SAMPLER_BINDING: - case GL_TEXTURE_BINDING_2D_ARRAY: - case GL_TEXTURE_BINDING_3D: case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE: case GL_TRANSFORM_FEEDBACK_BUFFER_START: case GL_UNIFORM_BUFFER_SIZE: diff --git a/GLESv2/yagl_texcompress.c b/GLESv2/yagl_texcompress.c index 0818348..6743afe 100644 --- a/GLESv2/yagl_texcompress.c +++ b/GLESv2/yagl_texcompress.c @@ -181,10 +181,6 @@ int yagl_texcompress_get_info(struct yagl_texcompress_format *format, GLsizei hblocks = (height + format->block_height - 1) / format->block_height; GLsizei num_components = 0, bpp = 0; - if ((width < 0) || (height < 0)) { - return 0; - } - if (src_size != (wblocks * hblocks * format->block_bytes)) { return 0; } |