summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2012-02-08 10:06:21 -0700
committerJosé Fonseca <[email protected]>2012-02-10 16:23:27 +0000
commitad9455314d9c5cb9b31af22116841ee3e642a55b (patch)
treedead64072d8d84b42ded1897911f82c1ed7bf29c /src/gallium/state_trackers
parent9646762261d976d34bee8c8b1dcda9656cec655c (diff)
st/wgl: refactor stw_pixelformat_init()
Replace duplicated code with add_color_format_variants() helper.
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/wgl/stw_pixelformat.c109
1 files changed, 51 insertions, 58 deletions
diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c
index a9667a36981..b74b71b1ba6 100644
--- a/src/gallium/state_trackers/wgl/stw_pixelformat.c
+++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c
@@ -210,80 +210,73 @@ stw_pixelformat_add(
}
}
-void
-stw_pixelformat_init( void )
+
+/**
+ * Add the depth/stencil/accum/ms variants for a particular color format.
+ */
+static void
+add_color_format_variants(const struct stw_pf_color_info *color,
+ boolean extended)
{
struct pipe_screen *screen = stw_dev->screen;
- unsigned i, j, k, l;
-
- assert( !stw_dev->pixelformat_count );
- assert( !stw_dev->pixelformat_extended_count );
+ unsigned ms, db, ds, acc;
+ unsigned bind_flags = PIPE_BIND_RENDER_TARGET;
- for(i = 0; i < Elements(stw_pf_multisample); ++i) {
- unsigned samples = stw_pf_multisample[i];
-
- /* FIXME: re-enabled MSAA when we can query it */
- if(samples)
- continue;
+ if (!extended) {
+ bind_flags |= PIPE_BIND_DISPLAY_TARGET;
+ }
- for(j = 0; j < Elements(stw_pf_color); ++j) {
- const struct stw_pf_color_info *color = &stw_pf_color[j];
-
- if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D,
- 0, PIPE_BIND_RENDER_TARGET |
- PIPE_BIND_DISPLAY_TARGET))
- continue;
-
- for(k = 0; k < Elements(stw_pf_doublebuffer); ++k) {
- unsigned doublebuffer = stw_pf_doublebuffer[k];
-
- for(l = 0; l < Elements(stw_pf_depth_stencil); ++l) {
- const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l];
-
- if(!screen->is_format_supported(screen, depth->format, PIPE_TEXTURE_2D,
- 0, PIPE_BIND_DEPTH_STENCIL))
- continue;
-
- stw_pixelformat_add( stw_dev, FALSE, color, depth, 0, doublebuffer, samples );
- stw_pixelformat_add( stw_dev, FALSE, color, depth, 16, doublebuffer, samples );
- }
- }
- }
+ if (!screen->is_format_supported(screen, color->format,
+ PIPE_TEXTURE_2D, 0, bind_flags)) {
+ return;
}
-
- /*
- * Same as above, but for the extended color formats (e.g, float) and without PIPE_BIND_DISPLAY_TARGET bit.
- */
- for(i = 0; i < Elements(stw_pf_multisample); ++i) {
- unsigned samples = stw_pf_multisample[i];
+
+ for (ms = 0; ms < Elements(stw_pf_multisample); ms++) {
+ unsigned samples = stw_pf_multisample[ms];
/* FIXME: re-enabled MSAA when we can query it */
- if(samples)
+ if (samples)
continue;
- for(j = 0; j < Elements(stw_pf_color_extended); ++j) {
- const struct stw_pf_color_info *color = &stw_pf_color_extended[j];
-
- if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D,
- 0, PIPE_BIND_RENDER_TARGET))
- continue;
+ for (db = 0; db < Elements(stw_pf_doublebuffer); db++) {
+ unsigned doublebuffer = stw_pf_doublebuffer[db];
- for(k = 0; k < Elements(stw_pf_doublebuffer); ++k) {
- unsigned doublebuffer = stw_pf_doublebuffer[k];
+ for (ds = 0; ds < Elements(stw_pf_depth_stencil); ds++) {
+ const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[ds];
- for(l = 0; l < Elements(stw_pf_depth_stencil); ++l) {
- const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l];
-
- if(!screen->is_format_supported(screen, depth->format, PIPE_TEXTURE_2D,
- 0, PIPE_BIND_DEPTH_STENCIL))
- continue;
+ if (!screen->is_format_supported(screen, depth->format,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_DEPTH_STENCIL)) {
+ continue;
+ }
- stw_pixelformat_add( stw_dev, TRUE, color, depth, 0, doublebuffer, samples );
- stw_pixelformat_add( stw_dev, TRUE, color, depth, 16, doublebuffer, samples );
+ for (acc = 0; acc < 2; acc++) {
+ stw_pixelformat_add(stw_dev, extended, color, depth,
+ acc * 16, doublebuffer, samples);
}
}
}
}
+}
+
+
+void
+stw_pixelformat_init( void )
+{
+ unsigned i;
+
+ assert( !stw_dev->pixelformat_count );
+ assert( !stw_dev->pixelformat_extended_count );
+
+ /* normal, displayable formats */
+ for (i = 0; i < Elements(stw_pf_color); i++) {
+ add_color_format_variants(&stw_pf_color[i], FALSE);
+ }
+
+ /* extended, pbuffer-only formats */
+ for (i = 0; i < Elements(stw_pf_color_extended); i++) {
+ add_color_format_variants(&stw_pf_color_extended[i], TRUE);
+ }
assert( stw_dev->pixelformat_count <= stw_dev->pixelformat_extended_count );
assert( stw_dev->pixelformat_extended_count <= STW_MAX_PIXELFORMATS );