diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index 1175995e6c1..23b565bc989 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -43,6 +43,7 @@ DRI_CONF_SECTION_DEBUG
DRI_CONF_FORCE_COMPAT_SHADERS(false)
DRI_CONF_FORCE_GL_NAMES_REUSE()
DRI_CONF_FORCE_GL_MAP_BUFFER_SYNCHRONIZED(false)
+ DRI_CONF_FORCE_GL_DEPTH_COMPONENT_TYPE_INT(false)
DRI_CONF_TRANSCODE_ETC(false)
DRI_CONF_TRANSCODE_ASTC(false)
DRI_CONF_ALLOW_COMPRESSED_FALLBACK(true)
diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c
index ef6ae1c2ed8..085b196b52d 100644
--- a/src/gallium/auxiliary/util/u_driconf.c
+++ b/src/gallium/auxiliary/util/u_driconf.c
@@ -69,6 +69,7 @@ u_driconf_fill_st_options(struct st_config_options *options,
query_bool_option(ignore_discard_framebuffer);
query_int_option(reuse_gl_names);
query_bool_option(force_gl_map_buffer_synchronized);
+ query_bool_option(force_gl_depth_component_type_int);
query_bool_option(transcode_etc);
query_bool_option(transcode_astc);
query_bool_option(allow_compressed_fallback);
diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h
index 26712fe7180..1bf6ea0ced6 100644
--- a/src/gallium/include/frontend/api.h
+++ b/src/gallium/include/frontend/api.h
@@ -198,6 +198,7 @@ struct st_config_options
bool force_integer_tex_nearest;
int reuse_gl_names;
bool force_gl_map_buffer_synchronized;
+ bool force_gl_depth_component_type_int;
bool transcode_etc;
bool transcode_astc;
bool allow_compressed_fallback;
diff --git a/src/mesa/main/consts_exts.h b/src/mesa/main/consts_exts.h
index 1a9be719da1..7a561ecd83a 100644
--- a/src/mesa/main/consts_exts.h
+++ b/src/mesa/main/consts_exts.h
@@ -926,6 +926,9 @@ struct gl_constants
/** Override GL_MAP_UNSYNCHRONIZED_BIT */
bool ForceMapBufferSynchronized;
+ /** Override GL_DEPTH_COMPONENT type from unsigned short to unsigned int */
+ bool ForceDepthComponentTypeInt;
+
/** GL_ARB_get_program_binary */
GLuint NumProgramBinaryFormats;
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 775f00caa4b..92ead66e516 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1196,6 +1196,8 @@ void st_init_extensions(struct pipe_screen *screen,
consts->ForceMapBufferSynchronized = options->force_gl_map_buffer_synchronized;
+ consts->ForceDepthComponentTypeInt = options->force_gl_depth_component_type_int;
+
consts->PrimitiveRestartFixedIndex =
screen->caps.primitive_restart_fixed_index;
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index b040c0c4f17..4c6e1fa26ca 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1328,6 +1328,11 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
bool is_renderbuffer = false;
enum pipe_texture_target pTarget;
+ if (ctx->Const.ForceDepthComponentTypeInt &&
+ internalFormat == GL_DEPTH_COMPONENT &&
+ type == GL_UNSIGNED_SHORT)
+ type = GL_UNSIGNED_INT;
+
if (target == GL_RENDERBUFFER) {
pTarget = PIPE_TEXTURE_2D;
is_renderbuffer = true;
diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf
index 253a1a1e8f4..d8cc6b63392 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -185,6 +185,10 @@ TODO: document the other workarounds.
+
+
+
+
diff --git a/src/util/driconf.h b/src/util/driconf.h
index 5b0481912c8..d46947b3bac 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -291,6 +291,9 @@
#define DRI_CONF_FORCE_GL_MAP_BUFFER_SYNCHRONIZED(def) \
DRI_CONF_OPT_B(force_gl_map_buffer_synchronized, def, "Override GL_MAP_UNSYNCHRONIZED_BIT.")
+#define DRI_CONF_FORCE_GL_DEPTH_COMPONENT_TYPE_INT(def) \
+ DRI_CONF_OPT_B(force_gl_depth_component_type_int, def, "Override GL_DEPTH_COMPONENT type from unsigned short to unsigned int")
+
#define DRI_CONF_TRANSCODE_ETC(def) \
DRI_CONF_OPT_B(transcode_etc, def, "Transcode ETC formats to DXTC if unsupported")