diff options
author | Vadym Shovkoplias <[email protected]> | 2018-02-13 11:38:22 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2018-02-13 13:24:31 -0700 |
commit | a553c54abf92533daf442073dd3408c35f57d8ba (patch) | |
tree | ad6a333c33af4ae7f045b2a47c5624a9810f1fbd /src/mesa/main | |
parent | b08d718703bc907d9cb99887f90ea80d7e91dc45 (diff) |
mesa: add glsl version query (v4)
Add support for GL_NUM_SHADING_LANGUAGE_VERSIONS
and glGetStringi for GL_SHADING_LANGUAGE_VERSION
v2:
- Combine similar functionality into
_mesa_get_shading_language_version() function.
- Change GLSL version return mechanism.
v3:
- Add return of empty string for GLSL ver 1.10.
- Move _mesa_get_shading_language_version() function
to src/mesa/main/version.c.
v4:
- Add OpenGL version check.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104915
Signed-off-by: Andriy Khulap <[email protected]>
Signed-off-by: Vadym Shovkoplias <[email protected]>
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/get.c | 11 | ||||
-rw-r--r-- | src/mesa/main/get_hash_params.py | 3 | ||||
-rw-r--r-- | src/mesa/main/getstring.c | 20 | ||||
-rw-r--r-- | src/mesa/main/version.c | 64 | ||||
-rw-r--r-- | src/mesa/main/version.h | 5 |
5 files changed, 103 insertions, 0 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index 57a211856c9..13d5e857ab2 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -143,6 +143,7 @@ enum value_extra { EXTRA_VERSION_31, EXTRA_VERSION_32, EXTRA_VERSION_40, + EXTRA_VERSION_43, EXTRA_API_GL, EXTRA_API_GL_CORE, EXTRA_API_ES2, @@ -522,6 +523,7 @@ extra_NV_primitive_restart[] = { static const int extra_version_30[] = { EXTRA_VERSION_30, EXTRA_END }; static const int extra_version_31[] = { EXTRA_VERSION_31, EXTRA_END }; static const int extra_version_32[] = { EXTRA_VERSION_32, EXTRA_END }; +static const int extra_version_43[] = { EXTRA_VERSION_43, EXTRA_END }; static const int extra_gl30_es3[] = { EXTRA_VERSION_30, @@ -1084,6 +1086,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu v->value_int = 0; } break; + /* GL 4.3 */ + case GL_NUM_SHADING_LANGUAGE_VERSIONS: + v->value_int = _mesa_get_shading_language_version(ctx, -1, NULL); + break; /* GL_ARB_draw_indirect */ case GL_DRAW_INDIRECT_BUFFER_BINDING: v->value_int = ctx->DrawIndirectBuffer->Name; @@ -1229,6 +1235,11 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d if (version >= 40) api_found = GL_TRUE; break; + case EXTRA_VERSION_43: + api_check = TRUE; + if (_mesa_is_desktop_gl(ctx) && version >= 43) + api_found = GL_TRUE; + break; case EXTRA_NEW_FRAG_CLAMP: if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP)) _mesa_update_state(ctx); diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index e127b6bdb23..5d2afedc437 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -543,6 +543,9 @@ descriptor=[ # GL_ARB_texture_cube_map_array [ "TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB", "LOC_CUSTOM, TYPE_INT, TEXTURE_CUBE_ARRAY_INDEX, extra_ARB_texture_cube_map_array_OES_texture_cube_map_array" ], + + # GL_NUM_SHADING_LANGUAGE_VERSIONS + [ "NUM_SHADING_LANGUAGE_VERSIONS", "LOC_CUSTOM, TYPE_INT, 0, extra_version_43" ], ]}, # Enums in OpenGL Core profile and ES 3.0 diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c index 931f6a476cb..3d5ae0b694b 100644 --- a/src/mesa/main/getstring.c +++ b/src/mesa/main/getstring.c @@ -32,6 +32,7 @@ #include "extensions.h" #include "mtypes.h" #include "macros.h" +#include "version.h" /** * Return the string for a glGetString(GL_SHADING_LANGUAGE_VERSION) query. @@ -186,6 +187,25 @@ _mesa_GetStringi(GLenum name, GLuint index) return (const GLubyte *) 0; } return _mesa_get_enabled_extension(ctx, index); + case GL_SHADING_LANGUAGE_VERSION: + { + char *version; + int num; + if (!_mesa_is_desktop_gl(ctx) || ctx->Version < 43) { + _mesa_error(ctx, GL_INVALID_ENUM, + "glGetStringi(GL_SHADING_LANGUAGE_VERSION): " + "supported only in GL4.3 and later"); + return (const GLubyte *) 0; + } + num = _mesa_get_shading_language_version(ctx, index, &version); + if (index >= num) { + _mesa_error(ctx, GL_INVALID_VALUE, + "glGetStringi(GL_SHADING_LANGUAGE_VERSION, index=%d)", + index); + return (const GLubyte *) 0; + } + return (const GLubyte *) version; + } default: _mesa_error(ctx, GL_INVALID_ENUM, "glGetStringi"); return (const GLubyte *) 0; diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c index 1fce8fe7ca9..d26baab8209 100644 --- a/src/mesa/main/version.c +++ b/src/mesa/main/version.c @@ -665,3 +665,67 @@ _mesa_get_device_uuid(struct gl_context *ctx, GLint *uuid) { ctx->Driver.GetDeviceUuid(ctx, (char*) uuid); } + +/** + * Get the i-th GLSL version string. If index=0, return the most recent + * supported version. + * \param ctx context to query + * \param index which version string to return, or -1 if none + * \param versionOut returns the vesrion string + * \return total number of shading language versions. + */ +int +_mesa_get_shading_language_version(const struct gl_context *ctx, + int index, + char **versionOut) +{ + int n = 0; + +#define GLSL_VERSION(S) \ + if (n++ == index) \ + *versionOut = S + + /* GLSL core */ + if (ctx->Const.GLSLVersion >= 460) + GLSL_VERSION("460"); + if (ctx->Const.GLSLVersion >= 450) + GLSL_VERSION("450"); + if (ctx->Const.GLSLVersion >= 440) + GLSL_VERSION("440"); + if (ctx->Const.GLSLVersion >= 430) + GLSL_VERSION("430"); + if (ctx->Const.GLSLVersion >= 420) + GLSL_VERSION("420"); + if (ctx->Const.GLSLVersion >= 410) + GLSL_VERSION("410"); + if (ctx->Const.GLSLVersion >= 400) + GLSL_VERSION("400"); + if (ctx->Const.GLSLVersion >= 330) + GLSL_VERSION("330"); + if (ctx->Const.GLSLVersion >= 150) + GLSL_VERSION("150"); + if (ctx->Const.GLSLVersion >= 140) + GLSL_VERSION("140"); + if (ctx->Const.GLSLVersion >= 130) + GLSL_VERSION("130"); + if (ctx->Const.GLSLVersion >= 120) + GLSL_VERSION("120"); + /* The GL spec says to return the empty string for GLSL 1.10 */ + if (ctx->Const.GLSLVersion >= 110) + GLSL_VERSION(""); + + /* GLSL es */ + if ((ctx->API == API_OPENGLES2 && ctx->Version >= 32) || + ctx->Extensions.ARB_ES3_2_compatibility) + GLSL_VERSION("320 es"); + if (_mesa_is_gles31(ctx) || ctx->Extensions.ARB_ES3_1_compatibility) + GLSL_VERSION("310 es"); + if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility) + GLSL_VERSION("300 es"); + if (ctx->API == API_OPENGLES2 || ctx->Extensions.ARB_ES2_compatibility) + GLSL_VERSION("100"); + +#undef GLSL_VERSION + + return n; +} diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h index 4cb5e5f0fa9..adfec6f8282 100644 --- a/src/mesa/main/version.h +++ b/src/mesa/main/version.h @@ -53,4 +53,9 @@ _mesa_get_driver_uuid(struct gl_context *ctx, GLint *uuid); extern void _mesa_get_device_uuid(struct gl_context *ctx, GLint *uuid); +extern int +_mesa_get_shading_language_version(const struct gl_context *ctx, + int index, + char **versionOut); + #endif /* VERSION_H */ |