[Mesa-dev] [PATCH 1/2] mesa: add context version routines

Kenneth Graunke kenneth at whitecape.org
Fri Aug 31 22:37:16 PDT 2012


On 08/31/2012 11:52 AM, Jordan Justen wrote:
> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
> ---
> 
> Based on the discussion July 26-27 in the thread
> "[PATCH 1/4] mesa: Add a Version field to the context
>  with VersionMajor*10+VersionMinor."
> 
>  src/mesa/main/version.h |   54 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 54 insertions(+)
> 
> diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h
> index 94a9855..6e13c6c 100644
> --- a/src/mesa/main/version.h
> +++ b/src/mesa/main/version.h
> @@ -27,6 +27,11 @@
>  #ifndef VERSION_H
>  #define VERSION_H
> 
> +#include "mtypes.h"
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> 
>  struct gl_context;
> 
> @@ -48,4 +53,53 @@ _mesa_compute_version(struct gl_context *ctx);
>  extern void
>  _mesa_override_glsl_version(struct gl_context *ctx);
> 
> +/**
> + * Merge major/minor into a comparable uint
> + */
> +static inline GLuint
> +_mesa_uint_version(int major, int minor)
> +{
> +    return major * 10 + minor;
> +}
> +
> +/**
> + * Return the GL major version of the context
> + */
> +static inline GLuint
> +_mesa_get_version_major(struct gl_context *ctx)
> +{
> +    return ctx->Version / 10;
> +}
> +
> +/**
> + * Return the GL minor version of the context
> + */
> +static inline GLuint
> +_mesa_get_version_minor(struct gl_context *ctx)
> +{
> +    return ctx->Version % 10;
> +}
> +
> +/**
> + * Sets the context version to major.minor
> + */
> +static inline void
> +_mesa_set_version(struct gl_context *ctx, int major, int minor)
> +{
> +    ctx->Version = _mesa_uint_version(major, minor);
> +}
> +
> +/**
> + * Checks if the context version is greater than or equal to major.minor
> + */
> +static inline GLboolean
> +_mesa_have_version(const struct gl_context *ctx, int major, int minor)
> +{
> +    return ctx->Version >= _mesa_uint_version(major, minor);
> +}
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
>  #endif /* VERSION_H */
> --
> 1.7.9.5

Whitespace errors on all of these functions.  Mesa is 3-space indent, not 4.


More information about the mesa-dev mailing list