From: Lepton Wu Date: Fri, 30 Aug 2019 17:30:53 +0000 (+0000) Subject: st/mesa: Allow zero as [level|layer]_override X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd98470a4692860004c1e9282808a638758c6f04;p=mesa.git st/mesa: Allow zero as [level|layer]_override This fix two dEQP tests for virgl: dEQP-EGL.functional.image.create.gles2_cubemap_positive_x_rgba_texture dEQP-EGL.functional.image.render_multiple_contexts.gles2_cubemap_positive_x_rgba8_texture Signed-off-by: Lepton Wu Reviewed-by: Marek Olšák --- diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 1ace61863ff..3f1c73fe66d 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -157,6 +157,9 @@ st_NewTextureObject(struct gl_context * ctx, GLuint name, GLenum target) if (!obj) return NULL; + obj->level_override = -1; + obj->layer_override = -1; + /* Pre-allocate a sampler views container to save a branch in the * fast path. */ @@ -754,8 +757,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; + stObj->layer_override = -1; + stObj->level_override = -1; 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 2fa08815085..664295dd852 100644 --- a/src/mesa/state_tracker/st_sampler_view.c +++ b/src/mesa/state_tracker/st_sampler_view.c @@ -527,13 +527,13 @@ st_create_texture_sampler_view_from_stobj(struct st_context *st, templ.format = format; - if (stObj->level_override) { + if (stObj->level_override >= 0) { 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) { + if (stObj->layer_override >= 0) { templ.u.tex.first_layer = templ.u.tex.last_layer = stObj->layer_override; } else { templ.u.tex.first_layer = stObj->base.MinLayer; @@ -578,12 +578,12 @@ 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, srgb_skip_decode) == view->format); assert(gl_target_to_pipe(stObj->base.Target) == view->target); - assert(stObj->level_override || + assert(stObj->level_override >= 0 || 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 || + assert(stObj->level_override >= 0 || last_level(stObj) == view->u.tex.last_level); + assert(stObj->layer_override >= 0 || stObj->base.MinLayer == view->u.tex.first_layer); + assert(stObj->layer_override >= 0 || last_layer(stObj) == view->u.tex.last_layer); + assert(stObj->layer_override < 0 || (stObj->layer_override == view->u.tex.first_layer && stObj->layer_override == view->u.tex.last_layer)); return view; diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index c5fc30cec5d..1fc36631c2e 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -164,15 +164,15 @@ struct st_texture_object */ enum pipe_format surface_format; - /* When non-zero, samplers should use this level instead of the level + /* When non-negative, 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; + int level_override; - /* When non-zero, samplers should use this layer instead of the one + /* When non-negative, samplers should use this layer instead of the one * specified by the GL state. * * This is used for EGL images and VDPAU interop, where imported @@ -180,7 +180,7 @@ struct st_texture_object * with different fields in the case of VDPAU) even though the GL state * describes one non-array texture per field. */ - uint layer_override; + int layer_override; /** * Set when the texture images of this texture object might not all be in diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c index 6a439b89d59..56075457073 100644 --- a/src/mesa/state_tracker/st_vdpau.c +++ b/src/mesa/state_tracker/st_vdpau.c @@ -191,7 +191,7 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access, struct pipe_resource *res; mesa_format texFormat; - uint layer_override = 0; + int layer_override = -1; if (output) { res = st_vdpau_output_surface_dma_buf(ctx, vdpSurface); @@ -248,7 +248,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->level_override = -1; stObj->layer_override = layer_override; _mesa_dirty_texobj(ctx, texObj); @@ -269,8 +269,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->level_override = 0; - stObj->layer_override = 0; + stObj->level_override = -1; + stObj->layer_override = -1; _mesa_dirty_texobj(ctx, texObj);