summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/common
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2016-08-20 16:10:20 -0400
committerIlia Mirkin <imirkin@alum.mit.edu>2016-08-23 18:30:30 -0400
commit528390021fdda0d8b39a50762003af743a22ff9f (patch)
treeacffd1a580fb77f4ed3ac851335cb02af8aa1f34 /src/mesa/drivers/dri/common
parent092f994a034b718f6170c631655ccaba8d2aa768 (diff)
downloadexternal_mesa3d-528390021fdda0d8b39a50762003af743a22ff9f.zip
external_mesa3d-528390021fdda0d8b39a50762003af743a22ff9f.tar.gz
external_mesa3d-528390021fdda0d8b39a50762003af743a22ff9f.tar.bz2
dri: add a way to request that modes have matching color/zs depths
Some GPUs, notably nv3x/nv4x can't render to mismatched color/zs framebuffer depths. Fallbacks can be done by the driver, with shadow surfaces, but no reason to encourage applications to select non-matching glx visuals. Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Diffstat (limited to 'src/mesa/drivers/dri/common')
-rw-r--r--src/mesa/drivers/dri/common/utils.c21
-rw-r--r--src/mesa/drivers/dri/common/utils.h2
2 files changed, 19 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/common/utils.c b/src/mesa/drivers/dri/common/utils.c
index 4b2e89c..c37d446 100644
--- a/src/mesa/drivers/dri/common/utils.c
+++ b/src/mesa/drivers/dri/common/utils.c
@@ -143,8 +143,10 @@ driGetRendererString( char * buffer, const char * hardware_name,
* \param msaa_samples Array of msaa sample count. 0 represents a visual
* without a multisample buffer.
* \param num_msaa_modes Number of entries in \c msaa_samples.
- * \param visType GLX visual type. Usually either \c GLX_TRUE_COLOR or
- * \c GLX_DIRECT_COLOR.
+ * \param enable_accum Add an accum buffer to the configs
+ * \param color_depth_match Whether the color depth must match the zs depth
+ * This forces 32-bit color to have 24-bit depth, and
+ * 16-bit color to have 16-bit depth.
*
* \returns
* Pointer to any array of pointers to the \c __DRIconfig structures created
@@ -158,7 +160,7 @@ driCreateConfigs(mesa_format format,
unsigned num_depth_stencil_bits,
const GLenum * db_modes, unsigned num_db_modes,
const uint8_t * msaa_samples, unsigned num_msaa_modes,
- GLboolean enable_accum)
+ GLboolean enable_accum, GLboolean color_depth_match)
{
static const uint32_t masks_table[][4] = {
/* MESA_FORMAT_B5G6R5_UNORM */
@@ -236,6 +238,19 @@ driCreateConfigs(mesa_format format,
for ( i = 0 ; i < num_db_modes ; i++ ) {
for ( h = 0 ; h < num_msaa_modes; h++ ) {
for ( j = 0 ; j < num_accum_bits ; j++ ) {
+ if (color_depth_match &&
+ (depth_bits[k] || stencil_bits[k])) {
+ /* Depth can really only be 0, 16, 24, or 32. A 32-bit
+ * color format still matches 24-bit depth, as there
+ * is an implicit 8-bit stencil. So really we just
+ * need to make sure that color/depth are both 16 or
+ * both non-16.
+ */
+ if ((depth_bits[k] + stencil_bits[k] == 16) !=
+ (red_bits + green_bits + blue_bits + alpha_bits == 16))
+ continue;
+ }
+
*c = malloc (sizeof **c);
modes = &(*c)->modes;
c++;
diff --git a/src/mesa/drivers/dri/common/utils.h b/src/mesa/drivers/dri/common/utils.h
index f6b8d7c..7be0465 100644
--- a/src/mesa/drivers/dri/common/utils.h
+++ b/src/mesa/drivers/dri/common/utils.h
@@ -45,7 +45,7 @@ driCreateConfigs(mesa_format format,
unsigned num_depth_stencil_bits,
const GLenum * db_modes, unsigned num_db_modes,
const uint8_t * msaa_samples, unsigned num_msaa_modes,
- GLboolean enable_accum);
+ GLboolean enable_accum, GLboolean color_depth_match);
__DRIconfig **driConcatConfigs(__DRIconfig **a,
__DRIconfig **b);