[Mesa-dev] [PATCH 20/24] st/mesa: simplify get_texture_format_swizzle
Marek Olšák
maraeo at gmail.com
Mon Jun 12 18:18:51 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
- Don't check GL_NONE (that was only for buffers).
- Don't use util_format_is_depth_or_stencil.
---
src/mesa/state_tracker/st_sampler_view.c | 43 +++++++++++++++-----------------
1 file changed, 20 insertions(+), 23 deletions(-)
diff --git a/src/mesa/state_tracker/st_sampler_view.c b/src/mesa/state_tracker/st_sampler_view.c
index f0cf9cb..e8a46a72 100644
--- a/src/mesa/state_tracker/st_sampler_view.c
+++ b/src/mesa/state_tracker/st_sampler_view.c
@@ -274,45 +274,42 @@ compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode,
return SWIZZLE_XYZW;
}
}
static unsigned
get_texture_format_swizzle(const struct st_context *st,
const struct st_texture_object *stObj,
unsigned glsl_version)
{
- GLenum baseFormat = _mesa_texture_base_format(&stObj->base);
+ GLenum baseFormat = _mesa_base_tex_image(&stObj->base)->_BaseFormat;
unsigned tex_swizzle;
-
- if (baseFormat != GL_NONE) {
- GLenum depth_mode = stObj->base.DepthMode;
- /* In ES 3.0, DEPTH_TEXTURE_MODE is expected to be GL_RED for textures
- * with depth component data specified with a sized internal format.
- */
- if (_mesa_is_gles3(st->ctx) &&
- util_format_is_depth_or_stencil(stObj->pt->format)) {
- const struct gl_texture_image *firstImage =
- _mesa_base_tex_image(&stObj->base);
- if (firstImage->InternalFormat != GL_DEPTH_COMPONENT &&
- firstImage->InternalFormat != GL_DEPTH_STENCIL &&
- firstImage->InternalFormat != GL_STENCIL_INDEX)
- depth_mode = GL_RED;
- }
- tex_swizzle = compute_texture_format_swizzle(baseFormat,
- depth_mode,
- stObj->pt->format,
- glsl_version);
- }
- else {
- tex_swizzle = SWIZZLE_XYZW;
+ GLenum depth_mode = stObj->base.DepthMode;
+
+ /* In ES 3.0, DEPTH_TEXTURE_MODE is expected to be GL_RED for textures
+ * with depth component data specified with a sized internal format.
+ */
+ if (_mesa_is_gles3(st->ctx) &&
+ (baseFormat == GL_DEPTH_COMPONENT ||
+ baseFormat == GL_DEPTH_STENCIL ||
+ baseFormat == GL_STENCIL_INDEX)) {
+ const struct gl_texture_image *firstImage =
+ _mesa_base_tex_image(&stObj->base);
+ if (firstImage->InternalFormat != GL_DEPTH_COMPONENT &&
+ firstImage->InternalFormat != GL_DEPTH_STENCIL &&
+ firstImage->InternalFormat != GL_STENCIL_INDEX)
+ depth_mode = GL_RED;
}
+ tex_swizzle = compute_texture_format_swizzle(baseFormat,
+ depth_mode,
+ stObj->pt->format,
+ glsl_version);
/* Combine the texture format swizzle with user's swizzle */
return swizzle_swizzle(stObj->base._Swizzle, tex_swizzle);
}
/**
* Return TRUE if the texture's sampler view swizzle is not equal to
* the texture's swizzle.
*
--
2.7.4
More information about the mesa-dev
mailing list