diff options
author | Nicolai Hähnle <[email protected]> | 2017-10-10 13:58:44 +0200 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2017-10-10 13:58:44 +0200 |
commit | 288dea076e3311530214aaaa53884a6d920b590a (patch) | |
tree | 1e7ab9427d7eea482da086be26a4d4b084eadca4 /src/mesa | |
parent | d245724399b7ac9e2ddf99d381f7fe092204006a (diff) |
st/mesa: fix import of EGL images with non-zero level or layer
In GL state, textures created from EGL images look like plain 2D textures
with a single level, so we use the existing layer_override facility and
add an analogous level_override one.
Fixes dEQP-EGL.functional.image.create.gles2_cubemap_{positive,negative}_{x,y,z}_rgba_texture
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_cb_eglimage.c | 3 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_sampler_view.c | 16 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.h | 15 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_vdpau.c | 2 |
5 files changed, 28 insertions, 10 deletions
diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c index e15b32ff199..bb092a2f6ef 100644 --- a/src/mesa/state_tracker/st_cb_eglimage.c +++ b/src/mesa/state_tracker/st_cb_eglimage.c @@ -226,12 +226,13 @@ st_bind_egl_image(struct gl_context *ctx, stimg->texture->width0, stimg->texture->height0, 1, 0, internalFormat, texFormat); - /* FIXME create a non-default sampler view from the stimg? */ pipe_resource_reference(&stObj->pt, stimg->texture); st_texture_release_all_sampler_views(st, stObj); pipe_resource_reference(&stImage->pt, stObj->pt); stObj->surface_format = stimg->format; + stObj->level_override = stimg->level; + stObj->layer_override = stimg->layer; _mesa_dirty_texobj(ctx, texObj); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index b0a95ecbc79..25ea52924d2 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -695,6 +695,8 @@ prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage, assert(!st_texture_image(texImage)->pt); _mesa_clear_texture_object(ctx, texObj, texImage); + stObj->layer_override = 0; + stObj->level_override = 0; pipe_resource_reference(&stObj->pt, NULL); /* oops, need to init this image again */ diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c index fbf0aaeb03a..014b4d26784 100644 --- a/src/mesa/state_tracker/st_sampler_view.c +++ b/src/mesa/state_tracker/st_sampler_view.c @@ -379,9 +379,12 @@ st_create_texture_sampler_view_from_stobj(struct st_context *st, templ.format = format; - templ.u.tex.first_level = stObj->base.MinLevel + stObj->base.BaseLevel; - templ.u.tex.last_level = last_level(stObj); - assert(templ.u.tex.first_level <= templ.u.tex.last_level); + if (stObj->level_override) { + templ.u.tex.first_level = templ.u.tex.last_level = stObj->level_override; + } else { + templ.u.tex.first_level = stObj->base.MinLevel + stObj->base.BaseLevel; + templ.u.tex.last_level = last_level(stObj); + } if (stObj->layer_override) { templ.u.tex.first_layer = templ.u.tex.last_layer = stObj->layer_override; } else { @@ -389,6 +392,7 @@ st_create_texture_sampler_view_from_stobj(struct st_context *st, templ.u.tex.last_layer = last_layer(stObj); } assert(templ.u.tex.first_layer <= templ.u.tex.last_layer); + assert(templ.u.tex.first_level <= templ.u.tex.last_level); templ.target = gl_target_to_pipe(stObj->base.Target); templ.swizzle_r = GET_SWZ(swizzle, 0); @@ -419,9 +423,9 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st, assert(!check_sampler_swizzle(st, stObj, view, glsl130_or_later)); assert(get_sampler_view_format(st, stObj, samp) == view->format); assert(gl_target_to_pipe(stObj->base.Target) == view->target); - assert(stObj->base.MinLevel + stObj->base.BaseLevel == - view->u.tex.first_level); - assert(last_level(stObj) == view->u.tex.last_level); + assert(stObj->level_override || + stObj->base.MinLevel + stObj->base.BaseLevel == view->u.tex.first_level); + assert(stObj->level_override || last_level(stObj) == view->u.tex.last_level); assert(stObj->layer_override || stObj->base.MinLayer == view->u.tex.first_layer); assert(stObj->layer_override || last_layer(stObj) == view->u.tex.last_layer); assert(!stObj->layer_override || diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 8448f4c6f02..0cde0c1f409 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -111,12 +111,21 @@ struct st_texture_object */ enum pipe_format surface_format; + /* When non-zero, samplers should use this level instead of the level + * range specified by the GL state. + * + * This is used for EGL images, which may correspond to a single level out + * of an imported pipe_resources with multiple mip levels. + */ + uint level_override; + /* When non-zero, samplers should use this layer instead of the one * specified by the GL state. * - * This is used for VDPAU interop, where imported pipe_resources may be - * array textures (containing layers with different fields) even though the - * GL state describes one non-array texture per field. + * This is used for EGL images and VDPAU interop, where imported + * pipe_resources may be cube, 3D, or array textures (containing layers + * with different fields in the case of VDPAU) even though the GL state + * describes one non-array texture per field. */ uint layer_override; diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c index bb4070eec34..19611e719a1 100644 --- a/src/mesa/state_tracker/st_vdpau.c +++ b/src/mesa/state_tracker/st_vdpau.c @@ -236,6 +236,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, pipe_resource_reference(&stImage->pt, res); stObj->surface_format = res->format; + stObj->level_override = 0; stObj->layer_override = layer_override; _mesa_dirty_texobj(ctx, texObj); @@ -256,6 +257,7 @@ st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access, st_texture_release_all_sampler_views(st, stObj); pipe_resource_reference(&stImage->pt, NULL); + stObj->level_override = 0; stObj->layer_override = 0; _mesa_dirty_texobj(ctx, texObj); |