aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorIlia Mirkin <[email protected]>2016-02-17 08:17:35 -0500
committerIlia Mirkin <[email protected]>2016-02-19 17:37:39 -0500
commit0b10ec1086d90de45ca2fab7b7b212508f50d1aa (patch)
tree889c9451ec53b03f9f32d347a19e4ac03fda70f8 /src/mesa/state_tracker
parente6f1a44d1407f3318d86ca1bcbc26c3479632e63 (diff)
st/mesa: force depth mode to GL_RED for sized depth/stencil formats
See commit 9db2098d for the i965 version of this. This fixes depth in a bunch of dEQP EXT_texture_border_clamp tests. And probably other ones as well. Signed-off-by: Ilia Mirkin <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Cc: [email protected]
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index ab4b2a9ef5f..4b7ad77b47a 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -32,6 +32,7 @@
*/
+#include "main/context.h"
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/samplerobj.h"
@@ -191,15 +192,29 @@ compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode,
static unsigned
-get_texture_format_swizzle(const struct st_texture_object *stObj,
+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);
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 st_texture_image *firstImage =
+ st_texture_image_const(_mesa_base_tex_image(&stObj->base));
+ if (firstImage->base.InternalFormat != GL_DEPTH_COMPONENT &&
+ firstImage->base.InternalFormat != GL_DEPTH_STENCIL &&
+ firstImage->base.InternalFormat != GL_STENCIL_INDEX)
+ depth_mode = GL_RED;
+ }
tex_swizzle = compute_texture_format_swizzle(baseFormat,
- stObj->base.DepthMode,
+ depth_mode,
stObj->pt->format,
glsl_version);
}
@@ -219,10 +234,11 @@ get_texture_format_swizzle(const struct st_texture_object *stObj,
* \param stObj the st texture object,
*/
static boolean
-check_sampler_swizzle(const struct st_texture_object *stObj,
+check_sampler_swizzle(const struct st_context *st,
+ const struct st_texture_object *stObj,
struct pipe_sampler_view *sv, unsigned glsl_version)
{
- unsigned swizzle = get_texture_format_swizzle(stObj, glsl_version);
+ unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl_version);
return ((sv->swizzle_r != GET_SWZ(swizzle, 0)) ||
(sv->swizzle_g != GET_SWZ(swizzle, 1)) ||
@@ -249,13 +265,13 @@ static unsigned last_layer(struct st_texture_object *stObj)
}
static struct pipe_sampler_view *
-st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
+st_create_texture_sampler_view_from_stobj(struct st_context *st,
struct st_texture_object *stObj,
enum pipe_format format,
unsigned glsl_version)
{
struct pipe_sampler_view templ;
- unsigned swizzle = get_texture_format_swizzle(stObj, glsl_version);
+ unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl_version);
u_sampler_view_default_template(&templ,
stObj->pt,
@@ -295,7 +311,7 @@ st_create_texture_sampler_view_from_stobj(struct pipe_context *pipe,
templ.swizzle_a = GET_SWZ(swizzle, 3);
}
- return pipe->create_sampler_view(pipe, stObj->pt, &templ);
+ return st->pipe->create_sampler_view(st->pipe, stObj->pt, &templ);
}
@@ -325,7 +341,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
/* if sampler view has changed dereference it */
if (*sv) {
- if (check_sampler_swizzle(stObj, *sv, glsl_version) ||
+ if (check_sampler_swizzle(st, stObj, *sv, glsl_version) ||
(format != (*sv)->format) ||
gl_target_to_pipe(stObj->base.Target) != (*sv)->target ||
stObj->base.MinLevel + stObj->base.BaseLevel != (*sv)->u.tex.first_level ||
@@ -337,7 +353,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
}
if (!*sv) {
- *sv = st_create_texture_sampler_view_from_stobj(st->pipe, stObj,
+ *sv = st_create_texture_sampler_view_from_stobj(st, stObj,
format, glsl_version);
} else if ((*sv)->context != st->pipe) {