mesa/st: ignore StencilSampling if stencil not part of the format
This avoids hitting assert in debug builds and incorrect rendering on release in case GL_DEPTH_STENCIL_TEXTURE_MODE has been set to GL_STENCIL_INDEX with a texture that does not have stencil. Cc: mesa-stable Signed-off-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25610>
This commit is contained in:
@@ -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 ||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user