diff options
-rw-r--r-- | src/mesa/state_tracker/st_sampler_view.c | 15 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.h | 9 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_vdpau.c | 20 |
3 files changed, 27 insertions, 17 deletions
diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c index 9fe0bfe..2b2fa8b 100644 --- a/src/mesa/state_tracker/st_sampler_view.c +++ b/src/mesa/state_tracker/st_sampler_view.c @@ -430,8 +430,12 @@ st_create_texture_sampler_view_from_stobj(struct st_context *st, 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); - templ.u.tex.first_layer = stObj->base.MinLayer; - templ.u.tex.last_layer = last_layer(stObj); + if (stObj->layer_override) { + templ.u.tex.first_layer = templ.u.tex.last_layer = stObj->layer_override; + } else { + templ.u.tex.first_layer = stObj->base.MinLayer; + templ.u.tex.last_layer = last_layer(stObj); + } assert(templ.u.tex.first_layer <= templ.u.tex.last_layer); templ.target = gl_target_to_pipe(stObj->base.Target); } @@ -478,8 +482,11 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st, assert(stObj->base.MinLevel + stObj->base.BaseLevel == view->u.tex.first_level); assert(last_level(stObj) == view->u.tex.last_level); - assert(stObj->base.MinLayer == view->u.tex.first_layer); - assert(last_layer(stObj) == view->u.tex.last_layer); + 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 || + (stObj->layer_override == view->u.tex.first_layer && + stObj->layer_override == view->u.tex.last_layer)); } } else { diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 730843a..0ce7989 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -108,6 +108,15 @@ struct st_texture_object */ enum pipe_format surface_format; + /* 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. + */ + uint layer_override; + /** The glsl version of the shader seen during the previous validation */ unsigned prev_glsl_version; /** The value of the sampler's sRGBDecode state at the previous validation */ diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c index 7912057..0273815 100644 --- a/src/mesa/state_tracker/st_vdpau.c +++ b/src/mesa/state_tracker/st_vdpau.c @@ -189,8 +189,8 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, struct st_texture_image *stImage = st_texture_image(texImage); struct pipe_resource *res; - struct pipe_sampler_view templ, **sampler_view; mesa_format texFormat; + uint layer_override = 0; if (output) { res = st_vdpau_output_surface_dma_buf(ctx, vdpSurface); @@ -201,8 +201,10 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, } else { res = st_vdpau_video_surface_dma_buf(ctx, vdpSurface, index); - if (!res) + if (!res) { res = st_vdpau_video_surface_gallium(ctx, vdpSurface, index); + layer_override = index & 1; + } } if (!res) { @@ -233,18 +235,8 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, st_texture_release_all_sampler_views(st, stObj); pipe_resource_reference(&stImage->pt, res); - u_sampler_view_default_template(&templ, res, res->format); - templ.u.tex.first_layer = index & 1; - templ.u.tex.last_layer = index & 1; - templ.swizzle_r = GET_SWZ(stObj->base._Swizzle, 0); - templ.swizzle_g = GET_SWZ(stObj->base._Swizzle, 1); - templ.swizzle_b = GET_SWZ(stObj->base._Swizzle, 2); - templ.swizzle_a = GET_SWZ(stObj->base._Swizzle, 3); - - sampler_view = st_texture_get_sampler_view(st, stObj); - *sampler_view = st->pipe->create_sampler_view(st->pipe, res, &templ); - stObj->surface_format = res->format; + stObj->layer_override = layer_override; _mesa_dirty_texobj(ctx, texObj); pipe_resource_reference(&res, NULL); @@ -264,6 +256,8 @@ 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->layer_override = 0; + _mesa_dirty_texobj(ctx, texObj); st_flush(st, NULL, 0); |