diff options
Diffstat (limited to 'src/gallium/state_trackers/wgl/shared/stw_framebuffer.c')
-rw-r--r-- | src/gallium/state_trackers/wgl/shared/stw_framebuffer.c | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c index c70b31a488..17c96c411f 100644 --- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c @@ -79,6 +79,14 @@ window_proc( return CallWindowProc( fb->WndProc, hWnd, uMsg, wParam, lParam ); } +static INLINE boolean +stw_is_supported_depth_stencil(enum pipe_format format) +{ + struct pipe_screen *screen = stw_dev->screen; + return screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); +} + /* Create a new framebuffer object which will correspond to the given HDC. */ struct stw_framebuffer * @@ -101,18 +109,43 @@ framebuffer_create( if (visual->depthBits == 0) depthFormat = PIPE_FORMAT_NONE; - else if (visual->depthBits <= 16) + else if (visual->depthBits <= 16 && + stw_is_supported_depth_stencil(PIPE_FORMAT_Z16_UNORM)) depthFormat = PIPE_FORMAT_Z16_UNORM; - else if (visual->depthBits <= 24) + else if (visual->depthBits <= 24 && visual->stencilBits != 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_X8Z24_UNORM)) { + depthFormat = PIPE_FORMAT_X8Z24_UNORM; + } + else if (visual->depthBits <= 24 && visual->stencilBits != 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_Z24X8_UNORM)) { + depthFormat = PIPE_FORMAT_Z24X8_UNORM; + } + else if (visual->depthBits <= 24 && visual->stencilBits == 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_S8Z24_UNORM)) { depthFormat = PIPE_FORMAT_S8Z24_UNORM; - else + } + else if (visual->depthBits <= 24 && visual->stencilBits == 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_Z24S8_UNORM)) { + depthFormat = PIPE_FORMAT_Z24S8_UNORM; + } + else if(stw_is_supported_depth_stencil(PIPE_FORMAT_Z32_UNORM)) { depthFormat = PIPE_FORMAT_Z32_UNORM; + } + else if(stw_is_supported_depth_stencil(PIPE_FORMAT_Z32_FLOAT)) { + depthFormat = PIPE_FORMAT_Z32_FLOAT; + } + else { + assert(0); + depthFormat = PIPE_FORMAT_NONE; + } - if (visual->stencilBits == 8) { - if (depthFormat == PIPE_FORMAT_S8Z24_UNORM) - stencilFormat = depthFormat; - else - stencilFormat = PIPE_FORMAT_S8_UNORM; + if (depthFormat == PIPE_FORMAT_S8Z24_UNORM || + depthFormat == PIPE_FORMAT_Z24S8_UNORM) { + stencilFormat = depthFormat; + } + else if (visual->stencilBits == 8 && + stw_is_supported_depth_stencil(PIPE_FORMAT_S8_UNORM)) { + stencilFormat = PIPE_FORMAT_S8_UNORM; } else { stencilFormat = PIPE_FORMAT_NONE; |