diff options
author | Michel Dänzer <daenzer@vmware.com> | 2010-03-12 18:24:34 +0100 |
---|---|---|
committer | Michel Dänzer <daenzer@vmware.com> | 2010-03-12 18:24:34 +0100 |
commit | c50477c255a34444720fb944c54373462ef39fb9 (patch) | |
tree | 9954fd618180e8742241700ca9a3c22b13bac703 | |
parent | 3bf13656d37788e88d342cece75fd0753292c010 (diff) |
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.
-rw-r--r-- | src/gallium/state_trackers/dri/dri_screen.c | 91 |
1 files changed, 47 insertions, 44 deletions
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index c55daf9bca..66a0e7128e 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -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) { |