GLenum depth_mode,
GLenum srgb_decode);
-int brw_get_texture_swizzle(const struct gl_texture_object *t);
+int brw_get_texture_swizzle(const struct gl_context *ctx,
+ const struct gl_texture_object *t);
/* gen7_wm_surface_state.c */
uint32_t gen7_surface_tiling_mode(uint32_t tiling);
* (except for GL_ALPHA); all other platforms need MOVs in the shader.
*/
if (!intel->is_haswell || alpha_depth)
- key->swizzles[s] = brw_get_texture_swizzle(t);
+ key->swizzles[s] = brw_get_texture_swizzle(ctx, t);
if (img->InternalFormat == GL_YCBCR_MESA) {
key->yuvtex_mask |= 1 << s;
*/
+#include "main/context.h"
#include "main/mtypes.h"
#include "main/samplerobj.h"
#include "program/prog_parameter.h"
* swizzling.
*/
int
-brw_get_texture_swizzle(const struct gl_texture_object *t)
+brw_get_texture_swizzle(const struct gl_context *ctx,
+ const struct gl_texture_object *t)
{
const struct gl_texture_image *img = t->Image[0][t->BaseLevel];
if (img->_BaseFormat == GL_DEPTH_COMPONENT ||
img->_BaseFormat == GL_DEPTH_STENCIL) {
- switch (t->DepthMode) {
+ GLenum depth_mode = t->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.
+ * Otherwise, it's left at the old default, GL_LUMINANCE.
+ */
+ if (_mesa_is_gles3(ctx) &&
+ img->InternalFormat != GL_DEPTH_COMPONENT &&
+ img->InternalFormat != GL_DEPTH_STENCIL) {
+ depth_mode = GL_RED;
+ }
+
+ switch (depth_mode) {
case GL_ALPHA:
swizzles[0] = SWIZZLE_ZERO;
swizzles[1] = SWIZZLE_ZERO;
(firstImage->_BaseFormat == GL_DEPTH_COMPONENT ||
firstImage->_BaseFormat == GL_DEPTH_STENCIL);
- const int swizzle =
- unlikely(alpha_depth) ? SWIZZLE_XYZW : brw_get_texture_swizzle(tObj);
-
+ const int swizzle = unlikely(alpha_depth)
+ ? SWIZZLE_XYZW : brw_get_texture_swizzle(ctx, tObj);
surf[7] =
SET_FIELD(swizzle_to_scs(GET_SWZ(swizzle, 0)), GEN7_SURFACE_SCS_R) |