mesa: implement glGetNamedStringARB()
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 26 Aug 2019 01:23:39 +0000 (11:23 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Wed, 20 Nov 2019 05:05:55 +0000 (05:05 +0000)
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Reviewed-by: Witold Baryluk <witold.baryluk@gmail.com>
src/mesa/main/shaderapi.c

index 3d764ff075ee0e9016a4fce778f2bf26f7e8d075..82f4bdc8210bb880768158f2a82ee5a38094b1f1 100644 (file)
@@ -3415,6 +3415,28 @@ GLvoid GLAPIENTRY
 _mesa_GetNamedStringARB(GLint namelen, const GLchar *name, GLsizei bufSize,
                         GLint *stringlen, GLchar *string)
 {
+   GET_CURRENT_CONTEXT(ctx);
+   const char *caller = "glGetNamedStringARB";
+
+   char *name_cp = copy_string(ctx, name, namelen, caller);
+   if (!name_cp)
+      return;
+
+   const char *source = _mesa_lookup_shader_include(ctx, name_cp);
+   if (!source) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "%s(no string associated with path %s)", caller, name_cp);
+      free(name_cp);
+      return;
+   }
+
+   size_t size = MIN2(strlen(source), bufSize - 1);
+   memcpy(string, source, size);
+   string[size] = '\0';
+
+   *stringlen = size;
+
+   free(name_cp);
 }
 
 GLvoid GLAPIENTRY