summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2009-04-06 23:09:02 +0100
committerJosé Fonseca <[email protected]>2009-04-06 23:09:02 +0100
commitb4c0e1f9e16ba61acd781ed6cbe448460e2b3153 (patch)
treeb4b5d5d80ba162fcfbb9ebb8ebd1f09f0e04aa5e /src
parentf4d744af24e07103f0f297b485f3dbca1fb7bc3b (diff)
stw: Choose a color buffer format that matches the visual.
The massive ifs are ugly, but it's not worth to automate this for just a handful of formats. Fixes conform bcolor.c.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/wgl/shared/stw_framebuffer.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
index 4641884f950..c289a8aeffc 100644
--- a/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
+++ b/src/gallium/state_trackers/wgl/shared/stw_framebuffer.c
@@ -70,6 +70,14 @@ window_proc(
}
static INLINE boolean
+stw_is_supported_color(enum pipe_format format)
+{
+ struct pipe_screen *screen = stw_dev->screen;
+ return screen->is_format_supported(screen, format, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
+}
+
+static INLINE boolean
stw_is_supported_depth_stencil(enum pipe_format format)
{
struct pipe_screen *screen = stw_dev->screen;
@@ -89,13 +97,33 @@ framebuffer_create(
struct stw_framebuffer *fb;
enum pipe_format colorFormat, depthFormat, stencilFormat;
- fb = CALLOC_STRUCT( stw_framebuffer );
- if (fb == NULL)
- return NULL;
-
/* Determine PIPE_FORMATs for buffers.
*/
- colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
+
+ if(visual->alphaBits <= 0 && visual->redBits <= 5 && visual->blueBits <= 6 && visual->greenBits <= 5 &&
+ stw_is_supported_color(PIPE_FORMAT_R5G6B5_UNORM)) {
+ colorFormat = PIPE_FORMAT_R5G6B5_UNORM;
+ }
+ else if(visual->alphaBits <= 0 && visual->redBits <= 8 && visual->blueBits <= 8 && visual->greenBits <= 8 &&
+ stw_is_supported_color(PIPE_FORMAT_X8R8G8B8_UNORM)) {
+ colorFormat = PIPE_FORMAT_X8R8G8B8_UNORM;
+ }
+ else if(visual->alphaBits <= 1 && visual->redBits <= 5 && visual->blueBits <= 5 && visual->greenBits <= 5 &&
+ stw_is_supported_color(PIPE_FORMAT_A1R5G5B5_UNORM)) {
+ colorFormat = PIPE_FORMAT_A1R5G5B5_UNORM;
+ }
+ else if(visual->alphaBits <= 4 && visual->redBits <= 4 && visual->blueBits <= 4 && visual->greenBits <= 4 &&
+ stw_is_supported_color(PIPE_FORMAT_A4R4G4B4_UNORM)) {
+ colorFormat = PIPE_FORMAT_A4R4G4B4_UNORM;
+ }
+ else if(visual->alphaBits <= 8 && visual->redBits <= 8 && visual->blueBits <= 8 && visual->greenBits <= 8 &&
+ stw_is_supported_color(PIPE_FORMAT_A8R8G8B8_UNORM)) {
+ colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
+ }
+ else {
+ assert(0);
+ return NULL;
+ }
if (visual->depthBits == 0)
depthFormat = PIPE_FORMAT_NONE;
@@ -141,6 +169,10 @@ framebuffer_create(
stencilFormat = PIPE_FORMAT_NONE;
}
+ fb = CALLOC_STRUCT( stw_framebuffer );
+ if (fb == NULL)
+ return NULL;
+
fb->stfb = st_create_framebuffer(
visual,
colorFormat,