[Mesa-dev] [PATCH 17/23] mesa: hook up UUID queries for driver and device

Timothy Arceri tarceri at itsqueeze.com
Fri Aug 4 01:54:20 UTC 2017


From: Andres Rodriguez <andresx7 at gmail.com>

v2: respective changes for new gallium interface
v3: fix UUID size asserts

Signed-off-by: Andres Rodriguez <andresx7 at gmail.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/mesa/main/dd.h                  | 15 +++++++++++++++
 src/mesa/main/get.c                 | 17 +++++++++++++++++
 src/mesa/main/version.c             | 13 +++++++++++++
 src/mesa/main/version.h             |  6 ++++++
 src/mesa/state_tracker/st_context.c | 22 ++++++++++++++++++++++
 5 files changed, 73 insertions(+)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index a1c9e8e793..7b2fe8b519 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1102,20 +1102,35 @@ struct dd_function_table {
     * Use a memory object as the backing data for a buffer object
     */
    GLboolean (*BufferDataMem)(struct gl_context *ctx,
                               GLenum target,
                               GLsizeiptrARB size,
                               struct gl_memory_object *memObj,
                               GLuint64 offset,
                               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);
+
    /*@}*/
 
    /**
     * \name GL_EXT_external_objects_fd interface
     */
    /*@{*/
    /**
     * Called to import a memory object. The caller relinquishes ownership
     * of fd after the call returns.
     *
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 75d77c80b0..93dd927bb0 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -33,20 +33,21 @@
 #include "extensions.h"
 #include "get.h"
 #include "macros.h"
 #include "mtypes.h"
 #include "state.h"
 #include "texcompress.h"
 #include "texstate.h"
 #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
  * in struct gl_context and then convert it to a bool or float according to
  * which of glGetIntegerv() glGetBooleanv() etc is being called.
  * Instead of generating code to do this, we can just record the enum
  * value and the offset into struct gl_context in an array of structs.  Then
  * in glGet*(), we lookup the struct for the enum in question, and use
  * the offset to get the int we need.
  *
@@ -832,20 +833,28 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
    case GL_TEXTURE_BINDING_RECTANGLE_NV:
    case GL_TEXTURE_BINDING_EXTERNAL_OES:
    case GL_TEXTURE_BINDING_CUBE_MAP_ARRAY:
    case GL_TEXTURE_BINDING_2D_MULTISAMPLE:
    case GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY:
       unit = ctx->Texture.CurrentUnit;
       v->value_int =
          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:
       {
          /* Note: we only check the 0th color attachment. */
          const struct gl_renderbuffer *rb =
             ctx->DrawBuffer->_ColorDrawBuffers[0];
          if (rb && _mesa_is_format_signed(rb->Format)) {
             /* Issue 17 of GL_EXT_packed_float:  If a component (such as
              * alpha) has zero bits, the component should not be considered
              * signed and so the bit for the respective component should be
@@ -2494,20 +2503,28 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
       return TYPE_INT;
 
    /* ARB_compute_variable_group_size */
    case GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB:
       if (!ctx->Extensions.ARB_compute_variable_group_size)
          goto invalid_enum;
       if (index >= 3)
          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:
    _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=%s)", func,
                _mesa_enum_to_string(pname));
    return TYPE_INVALID;
  invalid_value:
    _mesa_error(ctx, GL_INVALID_VALUE, "%s(pname=%s)", func,
                _mesa_enum_to_string(pname));
    return TYPE_INVALID;
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index f04c43ddf5..fe82b4674d 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -644,10 +644,23 @@ _mesa_compute_version(struct gl_context *ctx)
 
    case API_OPENGLES2:
       if (!ctx->Version) {
          _mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");
          return;
       }
       create_version_string(ctx, "OpenGL ES ");
       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);
+}
diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h
index ee7cb7501e..4cb5e5f0fa 100644
--- a/src/mesa/main/version.h
+++ b/src/mesa/main/version.h
@@ -40,11 +40,17 @@ _mesa_compute_version(struct gl_context *ctx);
 extern bool
 _mesa_override_gl_version_contextless(struct gl_constants *consts,
                                       gl_api *apiOut, GLuint *versionOut);
 
 extern void
 _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 */
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 2420e74363..ef2e73e741 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -658,20 +658,40 @@ st_set_background_context(struct gl_context *ctx,
                           struct util_queue_monitoring *queue_info)
 {
    struct st_context *st = ctx->st;
    struct st_manager *smapi =
       (struct st_manager*)st->iface.st_context_private;
 
    assert(smapi->set_background_context);
    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)
 {
    _mesa_init_shader_object_functions(functions);
    _mesa_init_sampler_object_functions(functions);
 
    st_init_blit_functions(functions);
    st_init_bufferobject_functions(screen, functions);
    st_init_clear_functions(functions);
    st_init_bitmap_functions(functions);
@@ -704,11 +724,13 @@ void st_init_driver_functions(struct pipe_screen *screen,
 
    st_init_vdpau_functions(functions);
 
    if (screen->get_param(screen, PIPE_CAP_STRING_MARKER))
       functions->EmitStringMarker = st_emit_string_marker;
 
    functions->Enable = st_Enable;
    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;
 }
-- 
2.13.3



More information about the mesa-dev mailing list