mesa: hook up UUID queries for driver and device
authorAndres Rodriguez <andresx7@gmail.com>
Wed, 12 Jul 2017 22:45:24 +0000 (18:45 -0400)
committerTimothy Arceri <tarceri@itsqueeze.com>
Sun, 6 Aug 2017 02:42:07 +0000 (12:42 +1000)
v2: respective changes for new gallium interface
v3: fix UUID size asserts

Signed-off-by: Andres Rodriguez <andresx7@gmail.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/mesa/main/dd.h
src/mesa/main/get.c
src/mesa/main/version.c
src/mesa/main/version.h
src/mesa/state_tracker/st_context.c

index a1c9e8e793ddf1d29a729a33b5e7af20e368ad7d..7b2fe8b519cd17321d41b31277fb2a0ccc00a0bf 100644 (file)
@@ -1109,6 +1109,21 @@ struct dd_function_table {
                               GLenum usage,
                               struct gl_buffer_object *bufObj);
 
+   /**
+    * Fill uuid with an unique identifier for this driver
+    *
+    * uuid must point to GL_UUID_SIZE_EXT bytes of available memory
+    */
+   void (*GetDriverUuid)(struct gl_context *ctx, char *uuid);
+
+   /**
+    * Fill uuid with an unique identifier for the device associated
+    * to this driver
+    *
+    * uuid must point to GL_UUID_SIZE_EXT bytes of available memory
+    */
+   void (*GetDeviceUuid)(struct gl_context *ctx, char *uuid);
+
    /*@}*/
 
    /**
index 75d77c80b0a5a0c3949115fca76e64476432d9fe..93dd927bb0117aae90cc873f513043d688322267 100644 (file)
@@ -40,6 +40,7 @@
 #include "framebuffer.h"
 #include "samplerobj.h"
 #include "stencil.h"
+#include "version.h"
 
 /* This is a table driven implemetation of the glGet*v() functions.
  * The basic idea is that most getters just look up an int somewhere
@@ -839,6 +840,14 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
          ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name;
       break;
 
+   /* GL_EXT_external_objects */
+   case GL_DRIVER_UUID_EXT:
+      _mesa_get_driver_uuid(ctx, v->value_int_4);
+      break;
+   case GL_DEVICE_UUID_EXT:
+      _mesa_get_device_uuid(ctx, v->value_int_4);
+      break;
+
    /* GL_EXT_packed_float */
    case GL_RGBA_SIGNED_COMPONENTS_EXT:
       {
@@ -2501,6 +2510,14 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
          goto invalid_value;
       v->value_int = ctx->Const.MaxComputeVariableGroupSize[index];
       return TYPE_INT;
+
+   /* GL_EXT_external_objects */
+   case GL_DRIVER_UUID_EXT:
+      _mesa_get_driver_uuid(ctx, v->value_int_4);
+      return TYPE_INT_4;
+   case GL_DEVICE_UUID_EXT:
+      _mesa_get_device_uuid(ctx, v->value_int_4);
+      return TYPE_INT_4;
    }
 
  invalid_enum:
index f04c43ddf57e28bafbffa47e132df5c4f20b4e05..fe82b4674d748b2a4d9a7f6b0f11c4db40a5e773 100644 (file)
@@ -651,3 +651,16 @@ _mesa_compute_version(struct gl_context *ctx)
       break;
    }
 }
+
+
+void
+_mesa_get_driver_uuid(struct gl_context *ctx, GLint *uuid)
+{
+   ctx->Driver.GetDriverUuid(ctx, (char*) uuid);
+}
+
+void
+_mesa_get_device_uuid(struct gl_context *ctx, GLint *uuid)
+{
+   ctx->Driver.GetDeviceUuid(ctx, (char*) uuid);
+}
index ee7cb7501eb48a30b4dde1f0a8b4704ae5dc4c5a..4cb5e5f0fa95a2970df9330f819c78ce3055f9a5 100644 (file)
@@ -47,4 +47,10 @@ _mesa_override_gl_version(struct gl_context *ctx);
 extern void
 _mesa_override_glsl_version(struct gl_constants *consts);
 
+extern void
+_mesa_get_driver_uuid(struct gl_context *ctx, GLint *uuid);
+
+extern void
+_mesa_get_device_uuid(struct gl_context *ctx, GLint *uuid);
+
 #endif /* VERSION_H */
index 2420e743630cf2a7ef9adbc003bd269dc51fa990..ef2e73e7415e5f80d40fd5b3a9e4f338b43bae7a 100644 (file)
@@ -665,6 +665,26 @@ st_set_background_context(struct gl_context *ctx,
    smapi->set_background_context(&st->iface, queue_info);
 }
 
+static void
+st_get_device_uuid(struct gl_context *ctx, char *uuid)
+{
+   struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+
+   assert(GL_UUID_SIZE_EXT >= PIPE_UUID_SIZE);
+   memset(uuid, 0, GL_UUID_SIZE_EXT);
+   screen->get_device_uuid(screen, uuid);
+}
+
+static void
+st_get_driver_uuid(struct gl_context *ctx, char *uuid)
+{
+   struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+
+   assert(GL_UUID_SIZE_EXT >= PIPE_UUID_SIZE);
+   memset(uuid, 0, GL_UUID_SIZE_EXT);
+   screen->get_driver_uuid(screen, uuid);
+}
+
 void st_init_driver_functions(struct pipe_screen *screen,
                               struct dd_function_table *functions)
 {
@@ -711,4 +731,6 @@ void st_init_driver_functions(struct pipe_screen *screen,
    functions->UpdateState = st_invalidate_state;
    functions->QueryMemoryInfo = st_query_memory_info;
    functions->SetBackgroundContext = st_set_background_context;
+   functions->GetDriverUuid = st_get_device_uuid;
+   functions->GetDeviceUuid = st_get_driver_uuid;
 }