[Mesa-dev] [PATCH] mesa: add glsl version query
Vadym Shovkoplias
vadim.shovkoplias at gmail.com
Tue Feb 6 16:32:05 UTC 2018
From: Vadym Shovkoplias <vadym.shovkoplias at globallogic.com>
Add support for GL_NUM_SHADING_LANGUAGE_VERSIONS
and glGetStringi for GL_SHADING_LANGUAGE_VERSION
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104915
Signed-off-by: Andriy Khulap <andriy.khulap at globallogic.com>
Signed-off-by: Vadym Shovkoplias <vadym.shovkoplias at globallogic.com>
---
src/mapi/glapi/gen/GL4x.xml | 1 +
src/mesa/main/get.c | 31 ++++++++++++++++++++++
src/mesa/main/get_hash_params.py | 3 +++
src/mesa/main/getstring.c | 56 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 91 insertions(+)
diff --git a/src/mapi/glapi/gen/GL4x.xml b/src/mapi/glapi/gen/GL4x.xml
index cd2e3b831e..2116286b35 100644
--- a/src/mapi/glapi/gen/GL4x.xml
+++ b/src/mapi/glapi/gen/GL4x.xml
@@ -42,6 +42,7 @@
<category name="4.3">
<enum name="SHADER_STORAGE_BARRIER_BIT" value="0x2000" />
+ <enum name="NUM_SHADING_LANGUAGE_VERSIONS" value="0x82E9" />
<enum name="MAX_COMBINED_SHADER_OUTPUT_RESOURCES" value="0x8F39" />
<enum name="SHADER_STORAGE_BUFFER" value="0x90D2"/>
<enum name="SHADER_STORAGE_BUFFER_BINDING" value="0x90D3"/>
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 516e8d174c..958bb62dc6 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1084,6 +1084,37 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
v->value_int = 0;
}
break;
+ /* GL_NUM_SHADING_LANGUAGE_VERSIONS */
+ case GL_NUM_SHADING_LANGUAGE_VERSIONS:
+ {
+ int num = 0;
+ /* GLSL es */
+ if (ctx->API == API_OPENGLES2 || ctx->Extensions.ARB_ES2_compatibility)
+ num++;
+ if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility)
+ num++;
+ if (_mesa_is_gles31(ctx) || ctx->Extensions.ARB_ES3_1_compatibility)
+ num++;
+ if ((ctx->API == API_OPENGLES2 && ctx->Version >= 32) ||
+ ctx->Extensions.ARB_ES3_2_compatibility)
+ num++;
+ /* GLSL core */
+ if (ctx->Const.GLSLVersion >= 120) num++;
+ if (ctx->Const.GLSLVersion >= 130) num++;
+ if (ctx->Const.GLSLVersion >= 140) num++;
+ if (ctx->Const.GLSLVersion >= 150) num++;
+ if (ctx->Const.GLSLVersion >= 330) num++;
+ if (ctx->Const.GLSLVersion >= 400) num++;
+ if (ctx->Const.GLSLVersion >= 410) num++;
+ if (ctx->Const.GLSLVersion >= 420) num++;
+ if (ctx->Const.GLSLVersion >= 430) num++;
+ if (ctx->Const.GLSLVersion >= 440) num++;
+ if (ctx->Const.GLSLVersion >= 450) num++;
+ if (ctx->Const.GLSLVersion >= 460) num++;
+
+ v->value_int = num;
+ }
+ break;
/* GL_ARB_draw_indirect */
case GL_DRAW_INDIRECT_BUFFER_BINDING:
v->value_int = ctx->DrawIndirectBuffer->Name;
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index df082af207..be716f6f6e 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, NO_EXTRA" ],
]},
# Enums in OpenGL Core profile and ES 3.0
diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
index 931f6a476c..50136b91b3 100644
--- a/src/mesa/main/getstring.c
+++ b/src/mesa/main/getstring.c
@@ -99,6 +99,60 @@ shading_language_version(struct gl_context *ctx)
}
+/**
+ * Return the string for a glGetStringi(GL_SHADING_LANGUAGE_VERSION) query.
+ */
+static const GLubyte *
+shading_language_version_index(struct gl_context *ctx, GLuint index)
+{
+ char *supported_versions[17];
+ int num_supported = 0;
+
+ /* Reversed order */
+ /* GLSL es */
+ if (ctx->API == API_OPENGLES2 || ctx->Extensions.ARB_ES2_compatibility)
+ supported_versions[num_supported++] = "100";
+ if (_mesa_is_gles3(ctx) || ctx->Extensions.ARB_ES3_compatibility)
+ supported_versions[num_supported++] = "300 es";
+ if (_mesa_is_gles31(ctx) || ctx->Extensions.ARB_ES3_1_compatibility)
+ supported_versions[num_supported++] = "310 es";
+ if ((ctx->API == API_OPENGLES2 && ctx->Version >= 32) ||
+ ctx->Extensions.ARB_ES3_2_compatibility)
+ supported_versions[num_supported++] = "320 es";
+
+ /* GLSL core */
+ if (ctx->Const.GLSLVersion >= 120)
+ supported_versions[num_supported++] = "120";
+ if (ctx->Const.GLSLVersion >= 130)
+ supported_versions[num_supported++] = "130";
+ if (ctx->Const.GLSLVersion >= 140)
+ supported_versions[num_supported++] = "140";
+ if (ctx->Const.GLSLVersion >= 150)
+ supported_versions[num_supported++] = "150";
+ if (ctx->Const.GLSLVersion >= 330)
+ supported_versions[num_supported++] = "330";
+ if (ctx->Const.GLSLVersion >= 400)
+ supported_versions[num_supported++] = "400";
+ if (ctx->Const.GLSLVersion >= 410)
+ supported_versions[num_supported++] = "410";
+ if (ctx->Const.GLSLVersion >= 420)
+ supported_versions[num_supported++] = "420";
+ if (ctx->Const.GLSLVersion >= 430)
+ supported_versions[num_supported++] = "430";
+ if (ctx->Const.GLSLVersion >= 440)
+ supported_versions[num_supported++] = "440";
+ if (ctx->Const.GLSLVersion >= 450)
+ supported_versions[num_supported++] = "450";
+ if (ctx->Const.GLSLVersion >= 460)
+ supported_versions[num_supported++] = "460";
+
+ if (index < num_supported)
+ return (const GLubyte *) supported_versions[num_supported - index - 1];
+ else
+ return (const GLubyte *) 0;
+}
+
+
/**
* Query string-valued state. The return value should _not_ be freed by
* the caller.
@@ -186,6 +240,8 @@ _mesa_GetStringi(GLenum name, GLuint index)
return (const GLubyte *) 0;
}
return _mesa_get_enabled_extension(ctx, index);
+ case GL_SHADING_LANGUAGE_VERSION:
+ return shading_language_version_index(ctx, index);
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetStringi");
return (const GLubyte *) 0;
--
2.14.1
More information about the mesa-dev
mailing list