diff options
author | Chad Versace <chad.versace@linux.intel.com> | 2013-01-04 13:13:40 -0800 |
---|---|---|
committer | Chad Versace <chad.versace@linux.intel.com> | 2013-01-04 14:08:31 -0800 |
commit | 9f032714ce447bd143c07629dfb8f2d2bcad34bc (patch) | |
tree | e88d3a99b675b29aefbf43928fbf311606816462 | |
parent | e393283c148d97413c7efb86369b56912e56b3f9 (diff) |
core,man: Accept WAFFLE_DONT_CARE for more config attrs
The affected attributes are:
- integer attributes
- WAFFLE_*_SIZE
- WAFFLE_SAMPLES
- boolean attributes
- WAFFLE_ACCUM_BUFFER
- WAFFLE_SAMPLE_BUFFERS
- WAFFLE_DOUBLE_BUFFERED
Waffle needs to accept DONT_CARE for these attributes for two reasons:
- Waffle attempts to follow the behavior of EGL and GLX when possible,
and both accept DONT_CARE for the affected attributes. (See spec
quotes in this patch).
- Waffle will soon acquire a function that returns a *list* of
matching configs, similar to eglChooseConfig. In order for that
function to return a maximumally sized list, we must pass DONT_CARE
to GLX and EGL, not the attribute's default value. As the EGL 1.4
states concerning eglChooseConfig: "If EGL_DONT_CARE is specified
as an attribute value, then the attribute will not be checked.".
Notes on commit 8c21708
-----------------------
Before commit 8c21708, WAFFLE_DONT_CARE was accepted for WAFFLE_*_SIZE and
WAFFLE_SAMPLES, and waffle passed DONT_CARE along to GLX and EGL. Commit
8c21708 unwisely chose to cease accepting WAFFLE_DONT_CARE for those
attributes. In that commit message, I misinterpreted the GLX and EGL
specs.
Even though this patch reinstates the acceptance of WAFFLE_DONT_CARE for
those attributes, it does not restore all the old behavior. Before commit
8c21708, the default value for those attributes was incorrectly DONT_CARE;
now it is 0.
Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
-rw-r--r-- | man/waffle_config.3.xml | 34 | ||||
-rw-r--r-- | src/waffle/core/wcore_config_attrs.c | 69 |
2 files changed, 76 insertions, 27 deletions
diff --git a/man/waffle_config.3.xml b/man/waffle_config.3.xml index 00631af..082ed92 100644 --- a/man/waffle_config.3.xml +++ b/man/waffle_config.3.xml @@ -354,7 +354,7 @@ struct waffle_config; <para> The default value for each size attribute is <constant>0</constant>. - The range of valid values is the non-negative integers. + Valid values are the non-negative integers and <constant>WAFFLE_DONT_CARE</constant>. If the requested size for a channel is 0, then any surface created with the config will lack that channel. If the requested size @@ -369,10 +369,20 @@ struct waffle_config; <term><constant>WAFFLE_SAMPLES</constant></term> <listitem> <para> - The valid values for <constant>WAFFLE_SAMPLE_BUFFERS</constant> are true and false. The default value is - false. If false, then any surface created with the config will not be multisampled. If true, the any surface + The default value of <constant>WAFFLE_SAMPLE_BUFFERS</constant> is false(0). + + Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>. + + The attribute specifies if a surface created with this config is double-buffered. + + If false, then any surface created with the config will not be multisampled. If true, the any surface created with the config will be multisampled, where the number of samples will be at least - <constant>WAFFLE_SAMPLES</constant>. The default value of <constant>WAFFLE_SAMPLES</constant> is 0. + <constant>WAFFLE_SAMPLES</constant>. + </para> + <para> + The default value of <constant>WAFFLE_SAMPLES</constant> is <constant>0</constant>. + + Valid values are the non-negative integers and <constant>WAFFLE_DONT_CARE</constant>. </para> </listitem> </varlistentry> @@ -381,8 +391,11 @@ struct waffle_config; <term><constant>WAFFLE_DOUBLE_BUFFERED</constant></term> <listitem> <para> - The valid values are true and false. The default is true. This attribute specifies if a surface created with - this config is double-buffered. + The default value is true(1). + + Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>. + + This attribute specifies if a surface created with this config is double-buffered. </para> </listitem> </varlistentry> @@ -391,12 +404,15 @@ struct waffle_config; <term><constant>WAFFLE_ACCUM_BUFFER</constant></term> <listitem> <para> - The valid values are true and false. The default is false. This attribute specifies if a surface created with - this config possesses an accumulation buffer. + The default value is false(0). + + Valid values are true(1), false(0), and <constant>WAFFLE_DONT_CARE</constant>. + + This attribute specifies if a surface created with this config possesses an accumulation buffer. </para> </listitem> </varlistentry> - + </variablelist> </refsect1> diff --git a/src/waffle/core/wcore_config_attrs.c b/src/waffle/core/wcore_config_attrs.c index 918ad31..bb9a0a1 100644 --- a/src/waffle/core/wcore_config_attrs.c +++ b/src/waffle/core/wcore_config_attrs.c @@ -35,6 +35,12 @@ #include "wcore_config_attrs.h" #include "wcore_error.h" +enum { + DEFAULT_ACCUM_BUFFERS = false, + DEFAULT_DOUBLE_BUFFERED = true, + DEFAULT_SAMPLE_BUFFERS = false, +}; + static bool check_keys(const int32_t attrib_list[]) { @@ -312,23 +318,43 @@ parse_misc(struct wcore_config_attrs *attrs, #define CASE_INT(enum_name, struct_memb) \ case enum_name: \ - if (value < 0) { \ + if (value < -1) { \ wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE, \ #enum_name " has bad value %d", value); \ return false; \ } \ - attrs->struct_memb = value; \ + else { \ + /* \ + * Pass WAFFLE_DONT_CARE to platform module. \ + * \ + * From the GLX 1.4 (2005.12.16) spec: \ + * GLX_DONT_CARE may be specified for all \ + * attributes except GLX_LEVEL. \ + * \ + * From the EGL 1.4 (2011.04.06) spec: \ + * EGL_DONT_CARE may be specified for all \ + * attributes except EGL_LEVEL and \ + * EGL_MATCH_NATIVE_PIXMAP. \ + */ \ + attrs->struct_memb = value; \ + } \ break; - #define CASE_BOOL(enum_name, struct_memb) \ + #define CASE_BOOL(enum_name, struct_memb, default_value) \ case enum_name: \ - if (value != true && value != false) { \ - wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE, \ - #enum_name " has bad value 0x%x, must be " \ - "true(1) or false(0)", value); \ - return false; \ + switch (value) { \ + case WAFFLE_DONT_CARE: \ + case true: \ + case false: \ + attrs->struct_memb = value; \ + break; \ + default: \ + wcore_errorf(WAFFLE_ERROR_BAD_ATTRIBUTE, \ + #enum_name " has bad value 0x%x, must be "\ + "true(1) or false(0), or " \ + "WAFFLE_DONT_CARE(-1)", value); \ + return false; \ } \ - attrs->struct_memb = value; \ break; case WAFFLE_CONTEXT_API: @@ -346,9 +372,9 @@ parse_misc(struct wcore_config_attrs *attrs, CASE_INT(WAFFLE_STENCIL_SIZE, stencil_size) CASE_INT(WAFFLE_SAMPLES, samples) - CASE_BOOL(WAFFLE_SAMPLE_BUFFERS, sample_buffers); - CASE_BOOL(WAFFLE_DOUBLE_BUFFERED, double_buffered); - CASE_BOOL(WAFFLE_ACCUM_BUFFER, accum_buffer); + CASE_BOOL(WAFFLE_SAMPLE_BUFFERS, sample_buffers, DEFAULT_SAMPLE_BUFFERS); + CASE_BOOL(WAFFLE_DOUBLE_BUFFERED, double_buffered, DEFAULT_DOUBLE_BUFFERED); + CASE_BOOL(WAFFLE_ACCUM_BUFFER, accum_buffer, DEFAULT_ACCUM_BUFFER); default: wcore_error_internal("%s", "bad attribute key should have " @@ -361,12 +387,19 @@ parse_misc(struct wcore_config_attrs *attrs, } } - attrs->rgb_size = attrs->red_size - + attrs->green_size - + attrs->blue_size; - - attrs->rgba_size = attrs->rgb_size - + attrs->alpha_size; + // Calculate rgb_size. + attrs->rgb_size = 0; + if (attrs->red_size != WAFFLE_DONT_CARE) + attrs->rgb_size += attrs->red_size; + if (attrs->green_size != WAFFLE_DONT_CARE) + attrs->rgb_size += attrs->green_size; + if (attrs->blue_size != WAFFLE_DONT_CARE) + attrs->rgb_size += attrs->blue_size; + + // Calculate rgba_size. + attrs->rgba_size = attrs->rgb_size; + if (attrs->alpha_size != WAFFLE_DONT_CARE) + attrs->rgba_size += attrs->alpha_size; return true; } |