summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/version.c
diff options
context:
space:
mode:
authorVadym Shovkoplias <[email protected]>2018-02-13 11:38:22 -0700
committerBrian Paul <[email protected]>2018-02-13 13:24:31 -0700
commita553c54abf92533daf442073dd3408c35f57d8ba (patch)
treead6a333c33af4ae7f045b2a47c5624a9810f1fbd /src/mesa/main/version.c
parentb08d718703bc907d9cb99887f90ea80d7e91dc45 (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/version.c')
-rw-r--r--src/mesa/main/version.c64
1 files changed, 64 insertions, 0 deletions
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;
+}