diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 4cad8b0c879..c7171ef1704 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -112,11 +112,20 @@ st_convert_sampler(const struct st_context *st, /* This is true if wrap modes are using the border color: */ (sampler->wrap_s | sampler->wrap_t | sampler->wrap_r) & 0x1) { GLenum texBaseFormat = _mesa_base_tex_image(texobj)->_BaseFormat; + + /* From OpenGL 4.3 spec, "Combined Depth/Stencil Textures": + * + * "The DEPTH_STENCIL_TEXTURE_MODE is ignored for non + * depth/stencil textures. + */ + const bool has_combined_ds = texBaseFormat == GL_DEPTH_STENCIL; + const GLboolean is_integer = - texobj->_IsIntegerFormat || texobj->StencilSampling || + texobj->_IsIntegerFormat || + (texobj->StencilSampling && has_combined_ds) || texBaseFormat == GL_STENCIL_INDEX; - if (texobj->StencilSampling) + if (texobj->StencilSampling && has_combined_ds) texBaseFormat = GL_STENCIL_INDEX; if (st->apply_texture_swizzle_to_border_color || diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c index 0b7b57ac7e5..5978c11c12d 100644 --- a/src/mesa/state_tracker/st_sampler_view.c +++ b/src/mesa/state_tracker/st_sampler_view.c @@ -361,10 +361,19 @@ st_get_sampler_view_format(const struct st_context *st, GLenum baseFormat = _mesa_base_tex_image(texObj)->_BaseFormat; format = texObj->surface_based ? texObj->surface_format : texObj->pt->format; + /* From OpenGL 4.3 spec, "Combined Depth/Stencil Textures": + * + * "The DEPTH_STENCIL_TEXTURE_MODE is ignored for non + * depth/stencil textures. + */ + const bool has_combined_ds = + baseFormat == GL_DEPTH_STENCIL; + if (baseFormat == GL_DEPTH_COMPONENT || baseFormat == GL_DEPTH_STENCIL || baseFormat == GL_STENCIL_INDEX) { - if (texObj->StencilSampling || baseFormat == GL_STENCIL_INDEX) + if ((texObj->StencilSampling && has_combined_ds) || + baseFormat == GL_STENCIL_INDEX) format = util_format_stencil_only(format); return format;