X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fstate_tracker%2Fst_atom_texture.c;h=04ba86448fc576ebc9d54a30104bca2275a1be1c;hb=a2a1a5805fd617e7f3cc8be44dd79b50da07ebb9;hp=ed9a44429b4271d628fabd0d01fc6d66000916e7;hpb=d82bd7eb060cf2fbb7282da38f28f6e7ea705e12;p=mesa.git diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index ed9a44429b4..04ba86448fc 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -35,6 +35,7 @@ #include "main/macros.h" #include "main/mtypes.h" #include "main/samplerobj.h" +#include "main/teximage.h" #include "main/texobj.h" #include "program/prog_instruction.h" @@ -175,12 +176,11 @@ compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode, static unsigned get_texture_format_swizzle(const struct st_texture_object *stObj) { - const struct gl_texture_image *texImage = - stObj->base.Image[0][stObj->base.BaseLevel]; + GLenum baseFormat = _mesa_texture_base_format(&stObj->base); unsigned tex_swizzle; - if (texImage) { - tex_swizzle = compute_texture_format_swizzle(texImage->_BaseFormat, + if (baseFormat != GL_NONE) { + tex_swizzle = compute_texture_format_swizzle(baseFormat, stObj->base.DepthMode, stObj->pt->format); } @@ -223,7 +223,7 @@ static unsigned last_level(struct st_texture_object *stObj) static unsigned last_layer(struct st_texture_object *stObj) { - if (stObj->base.Immutable) + if (stObj->base.Immutable && stObj->pt->array_size > 1) return MIN2(stObj->base.MinLayer + stObj->base.NumLayers - 1, stObj->pt->array_size - 1); return stObj->pt->array_size - 1; @@ -287,16 +287,22 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st, enum pipe_format format) { struct pipe_sampler_view **sv; - + const struct st_texture_image *firstImage; if (!stObj || !stObj->pt) { return NULL; } sv = st_texture_get_sampler_view(st, stObj); - if (stObj->base.StencilSampling && - util_format_is_depth_and_stencil(format)) - format = util_format_stencil_only(format); + if (util_format_is_depth_and_stencil(format)) { + if (stObj->base.StencilSampling) + format = util_format_stencil_only(format); + else { + firstImage = st_texture_image_const(_mesa_base_tex_image(&stObj->base)); + if (firstImage->base._BaseFormat == GL_STENCIL_INDEX) + format = util_format_stencil_only(format); + } + } /* if sampler view has changed dereference it */ if (*sv) {