Commit c50477c2 authored by Michel Dänzer's avatar Michel Dänzer
Browse files

st/dri: Always try to set up R5G6B5 configs.

Allows compiz to work in depth 16.

The DRI2 getBuffersWithFormat hook is only required for 16/32 bit depth
buffers, for colour buffers the only requirement is that the format matches
the drawable depth, which we can't check here.
parent 3bf13656
......@@ -80,6 +80,9 @@ dri_fill_in_modes(struct dri_screen *screen,
unsigned pixel_bits)
{
__DRIconfig **configs = NULL;
__DRIconfig **configs_r5g6b5 = NULL;
__DRIconfig **configs_a8r8g8b8 = NULL;
__DRIconfig **configs_x8r8g8b8 = NULL;
unsigned num_modes;
uint8_t depth_bits_array[5];
uint8_t stencil_bits_array[5];
......@@ -117,25 +120,23 @@ dri_fill_in_modes(struct dri_screen *screen,
pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8R8G8B8_UNORM,
PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
/* we support buffers with different depths only if we can tell the driver
* the actual depth of each of them. */
if (screen->sPriv->dri2.loader
&& (screen->sPriv->dri2.loader->base.version > 2)
&& (screen->sPriv->dri2.loader->getBuffersWithFormat != NULL)) {
pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_R5G6B5_UNORM,
PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
/* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
if (screen->sPriv->dri2.loader &&
(screen->sPriv->dri2.loader->base.version > 2) &&
(screen->sPriv->dri2.loader->getBuffersWithFormat != NULL)) {
pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_R5G6B5_UNORM,
PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
} else {
pf_z16 = FALSE;
pf_z32 = FALSE;
pf_r5g6b5 = FALSE;
}
if (pf_z16) {
......@@ -164,41 +165,43 @@ dri_fill_in_modes(struct dri_screen *screen,
num_modes =
depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
if (pixel_bits == 16 && pf_r5g6b5) {
configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
depth_bits_array, stencil_bits_array,
depth_buffer_factor, back_buffer_modes,
back_buffer_factor,
msaa_samples_array, 1);
if (pf_r5g6b5)
configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
depth_bits_array, stencil_bits_array,
depth_buffer_factor, back_buffer_modes,
back_buffer_factor,
msaa_samples_array, 1);
if (pf_a8r8g8b8)
configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
depth_bits_array,
stencil_bits_array,
depth_buffer_factor,
back_buffer_modes,
back_buffer_factor,
msaa_samples_array, 1);
if (pf_x8r8g8b8)
configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
depth_bits_array,
stencil_bits_array,
depth_buffer_factor,
back_buffer_modes,
back_buffer_factor,
msaa_samples_array, 1);
if (pixel_bits == 16) {
configs = configs_r5g6b5;
if (configs_a8r8g8b8)
configs = configs ? driConcatConfigs(configs, configs_a8r8g8b8) : configs_a8r8g8b8;
if (configs_x8r8g8b8)
configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
} else {
__DRIconfig **configs_a8r8g8b8 = NULL;
__DRIconfig **configs_x8r8g8b8 = NULL;
if (pf_a8r8g8b8)
configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
depth_bits_array,
stencil_bits_array,
depth_buffer_factor,
back_buffer_modes,
back_buffer_factor,
msaa_samples_array, 1);
if (pf_x8r8g8b8)
configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
depth_bits_array,
stencil_bits_array,
depth_buffer_factor,
back_buffer_modes,
back_buffer_factor,
msaa_samples_array, 1);
if (configs_a8r8g8b8 && configs_x8r8g8b8)
configs = driConcatConfigs(configs_x8r8g8b8, configs_a8r8g8b8);
else if (configs_a8r8g8b8)
configs = configs_a8r8g8b8;
else if (configs_x8r8g8b8)
configs = configs_x8r8g8b8;
else
configs = NULL;
configs = configs_a8r8g8b8;
if (configs_x8r8g8b8)
configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
if (configs_r5g6b5)
configs = configs ? driConcatConfigs(configs, configs_r5g6b5) : configs_r5g6b5;
}
if (configs == NULL) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment