glamor: Compute GLSL version from GL_SHADING_LANGUAGE_VERSION (v3)
Use code from Piglit project to compute GLSL version for either GL or GLES. The Piglit code was originally written by Chad Versace. v2: bail if the parse fails (requested by Eric Anholt) v3: Use version 1.20 for GLES until we fix our programs (Eric Anholt) Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
parent
dcb3d74ba8
commit
ff3195aadd
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright © 2008 Intel Corporation
|
||||
* Copyright © 2008,2011 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -23,7 +23,7 @@
|
|||
* Authors:
|
||||
* Eric Anholt <eric@anholt.net>
|
||||
* Zhigang Gong <zhigang.gong@linux.intel.com>
|
||||
*
|
||||
* Chad Versace <chad.versace@linux.intel.com>
|
||||
*/
|
||||
|
||||
/** @file glamor.c
|
||||
|
@ -336,7 +336,11 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
int gl_version;
|
||||
int glsl_major, glsl_minor;
|
||||
int max_viewport_size[2];
|
||||
const char *shading_version_string;
|
||||
int shading_version_offset;
|
||||
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
|
||||
if (flags & ~GLAMOR_VALID_FLAGS) {
|
||||
|
@ -380,14 +384,40 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
|
||||
gl_version = epoxy_gl_version();
|
||||
|
||||
/* Would be nice to have a cleaner test for GLSL 1.30 support,
|
||||
* but for now this should suffice
|
||||
*/
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && gl_version >= 30)
|
||||
glamor_priv->glsl_version = 130;
|
||||
else
|
||||
glamor_priv->glsl_version = 120;
|
||||
shading_version_string = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||
|
||||
if (!shading_version_string) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to get GLSL version\n",
|
||||
screen->myNum);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
shading_version_offset = 0;
|
||||
if (strncmp("OpenGL ES GLSL ES ", shading_version_string, 18) == 0)
|
||||
shading_version_offset = 18;
|
||||
|
||||
if (sscanf(shading_version_string + shading_version_offset,
|
||||
"%i.%i",
|
||||
&glsl_major,
|
||||
&glsl_minor) != 2) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to parse GLSL version string %s\n",
|
||||
screen->myNum, shading_version_string);
|
||||
goto fail;
|
||||
}
|
||||
glamor_priv->glsl_version = glsl_major * 100 + glsl_minor;
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) {
|
||||
/* Force us back to the base version of our programs on an ES
|
||||
* context, anyway. Basically glamor only uses desktop 1.20
|
||||
* or 1.30 currently. 1.30's new features are also present in
|
||||
* ES 3.0, but our glamor_program.c constructions use a lot of
|
||||
* compatibility features (to reduce the diff between 1.20 and
|
||||
* 1.30 programs).
|
||||
*/
|
||||
glamor_priv->glsl_version = 120;
|
||||
}
|
||||
|
||||
/* We'd like to require GL_ARB_map_buffer_range or
|
||||
* GL_OES_map_buffer_range, since it offers more information to
|
||||
|
|
Loading…
Reference in New Issue
Block a user