glthread: add custom marshalling for glNamedBuffer(Sub)DataEXT
authorMarek Olšák <marek.olsak@amd.com>
Tue, 25 Feb 2020 01:30:23 +0000 (20:30 -0500)
committerMarge Bot <eric+marge@anholt.net>
Fri, 6 Mar 2020 01:06:14 +0000 (01:06 +0000)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3948>

src/mapi/glapi/gen/EXT_direct_state_access.xml
src/mesa/main/marshal.c
src/mesa/main/marshal.h

index 0fe9ebcd647a634790874a9374f1ada0e3372d9a..3888dd34e6e25bdf4ea212d6e90c9b87367c8467 100644 (file)
 
    <!-- OpenGL 1.5 -->
 
-   <function name="NamedBufferDataEXT">
+   <function name="NamedBufferDataEXT" marshal="custom">
       <param name="buffer" type="GLuint" />
       <param name="size" type="GLsizeiptr" />
       <param name="data" type="const GLvoid *" />
       <param name="usage" type="GLenum" />
    </function>
 
-   <function name="NamedBufferSubDataEXT">
+   <function name="NamedBufferSubDataEXT" marshal="custom">
       <param name="buffer" type="GLuint" />
       <param name="offset" type="GLintptr" />
       <param name="size" type="GLsizeiptr" />
index 9014cb1ff2303f0e6312cd5d2c23dc62fa90be61..9c9d67208784e3a2c613f853daa3e6c8c4287f7b 100644 (file)
@@ -192,6 +192,7 @@ struct marshal_cmd_BufferData
    const GLvoid *data_external_mem;
    bool data_null; /* If set, no data follows for "data" */
    bool named;
+   bool ext_dsa;
    /* Next size bytes are GLubyte data[size] */
 };
 
@@ -211,7 +212,10 @@ _mesa_unmarshal_BufferData(struct gl_context *ctx,
    else
       data = (const void *) (cmd + 1);
 
-   if (cmd->named) {
+   if (cmd->ext_dsa) {
+      CALL_NamedBufferDataEXT(ctx->CurrentServerDispatch,
+                              (target_or_name, size, data, usage));
+   } else if (cmd->named) {
       CALL_NamedBufferData(ctx->CurrentServerDispatch,
                            (target_or_name, size, data, usage));
    } else {
@@ -227,10 +231,17 @@ _mesa_unmarshal_NamedBufferData(struct gl_context *ctx,
    unreachable("never used - all BufferData variants use DISPATCH_CMD_BufferData");
 }
 
+void
+_mesa_unmarshal_NamedBufferDataEXT(struct gl_context *ctx,
+                                   const struct marshal_cmd_BufferData *cmd)
+{
+   unreachable("never used - all BufferData variants use DISPATCH_CMD_BufferData");
+}
+
 static void
 _mesa_marshal_BufferData_merged(GLuint target_or_name, GLsizeiptr size,
                                 const GLvoid *data, GLenum usage, bool named,
-                                const char *func)
+                                bool ext_dsa, const char *func)
 {
    GET_CURRENT_CONTEXT(ctx);
    bool external_mem = !named &&
@@ -262,6 +273,7 @@ _mesa_marshal_BufferData_merged(GLuint target_or_name, GLsizeiptr size,
    cmd->usage = usage;
    cmd->data_null = !data;
    cmd->named = named;
+   cmd->ext_dsa = ext_dsa;
    cmd->data_external_mem = data;
 
    if (copy_data) {
@@ -275,7 +287,7 @@ void GLAPIENTRY
 _mesa_marshal_BufferData(GLenum target, GLsizeiptr size, const GLvoid * data,
                          GLenum usage)
 {
-   _mesa_marshal_BufferData_merged(target, size, data, usage, false,
+   _mesa_marshal_BufferData_merged(target, size, data, usage, false, false,
                                    "BufferData");
 }
 
@@ -283,10 +295,18 @@ void GLAPIENTRY
 _mesa_marshal_NamedBufferData(GLuint buffer, GLsizeiptr size,
                               const GLvoid * data, GLenum usage)
 {
-   _mesa_marshal_BufferData_merged(buffer, size, data, usage, true,
+   _mesa_marshal_BufferData_merged(buffer, size, data, usage, true, false,
                                    "NamedBufferData");
 }
 
+void GLAPIENTRY
+_mesa_marshal_NamedBufferDataEXT(GLuint buffer, GLsizeiptr size,
+                                 const GLvoid *data, GLenum usage)
+{
+   _mesa_marshal_BufferData_merged(buffer, size, data, usage, true, true,
+                                   "NamedBufferDataEXT");
+}
+
 
 /* BufferSubData: marshalled asynchronously */
 struct marshal_cmd_BufferSubData
@@ -296,6 +316,7 @@ struct marshal_cmd_BufferSubData
    GLintptr offset;
    GLsizeiptr size;
    bool named;
+   bool ext_dsa;
    /* Next size bytes are GLubyte data[size] */
 };
 
@@ -308,7 +329,10 @@ _mesa_unmarshal_BufferSubData(struct gl_context *ctx,
    const GLsizeiptr size = cmd->size;
    const void *data = (const void *) (cmd + 1);
 
-   if (cmd->named) {
+   if (cmd->ext_dsa) {
+      CALL_NamedBufferSubDataEXT(ctx->CurrentServerDispatch,
+                                 (target_or_name, offset, size, data));
+   } else if (cmd->named) {
       CALL_NamedBufferSubData(ctx->CurrentServerDispatch,
                               (target_or_name, offset, size, data));
    } else {
@@ -324,10 +348,17 @@ _mesa_unmarshal_NamedBufferSubData(struct gl_context *ctx,
    unreachable("never used - all BufferSubData variants use DISPATCH_CMD_BufferSubData");
 }
 
+void
+_mesa_unmarshal_NamedBufferSubDataEXT(struct gl_context *ctx,
+                                      const struct marshal_cmd_BufferSubData *cmd)
+{
+   unreachable("never used - all BufferSubData variants use DISPATCH_CMD_BufferSubData");
+}
+
 static void
 _mesa_marshal_BufferSubData_merged(GLuint target_or_name, GLintptr offset,
                                    GLsizeiptr size, const GLvoid *data,
-                                   bool named, const char *func)
+                                   bool named, bool ext_dsa, const char *func)
 {
    GET_CURRENT_CONTEXT(ctx);
    size_t cmd_size = sizeof(struct marshal_cmd_BufferSubData) + size;
@@ -354,6 +385,7 @@ _mesa_marshal_BufferSubData_merged(GLuint target_or_name, GLintptr offset,
    cmd->offset = offset;
    cmd->size = size;
    cmd->named = named;
+   cmd->ext_dsa = ext_dsa;
 
    char *variable_data = (char *) (cmd + 1);
    memcpy(variable_data, data, size);
@@ -365,7 +397,7 @@ _mesa_marshal_BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
                             const GLvoid * data)
 {
    _mesa_marshal_BufferSubData_merged(target, offset, size, data, false,
-                                      "BufferSubData");
+                                      false, "BufferSubData");
 }
 
 void GLAPIENTRY
@@ -373,5 +405,13 @@ _mesa_marshal_NamedBufferSubData(GLuint buffer, GLintptr offset,
                                  GLsizeiptr size, const GLvoid * data)
 {
    _mesa_marshal_BufferSubData_merged(buffer, offset, size, data, true,
-                                      "NamedBufferSubData");
+                                      false, "NamedBufferSubData");
+}
+
+void GLAPIENTRY
+_mesa_marshal_NamedBufferSubDataEXT(GLuint buffer, GLintptr offset,
+                                    GLsizeiptr size, const GLvoid * data)
+{
+   _mesa_marshal_BufferSubData_merged(buffer, offset, size, data, true,
+                                      true, "NamedBufferSubDataEXT");
 }
index c4b738aeb113ffee2a1cb32e70a21438ed24f94d..acc6a02b920b6e14662429a489d6fa895b4d4fce 100644 (file)
@@ -173,6 +173,10 @@ void
 _mesa_unmarshal_NamedBufferData(struct gl_context *ctx,
                                 const struct marshal_cmd_BufferData *cmd);
 
+void
+_mesa_unmarshal_NamedBufferDataEXT(struct gl_context *ctx,
+                                   const struct marshal_cmd_BufferData *cmd);
+
 void GLAPIENTRY
 _mesa_marshal_BufferData(GLenum target, GLsizeiptr size, const GLvoid * data,
                          GLenum usage);
@@ -181,6 +185,10 @@ void GLAPIENTRY
 _mesa_marshal_NamedBufferData(GLuint buffer, GLsizeiptr size,
                               const GLvoid * data, GLenum usage);
 
+void GLAPIENTRY
+_mesa_marshal_NamedBufferDataEXT(GLuint buffer, GLsizeiptr size,
+                                 const GLvoid *data, GLenum usage);
+
 void
 _mesa_unmarshal_BufferSubData(struct gl_context *ctx,
                               const struct marshal_cmd_BufferSubData *cmd);
@@ -189,6 +197,10 @@ void
 _mesa_unmarshal_NamedBufferSubData(struct gl_context *ctx,
                                    const struct marshal_cmd_BufferSubData *cmd);
 
+void
+_mesa_unmarshal_NamedBufferSubDataEXT(struct gl_context *ctx,
+                                      const struct marshal_cmd_BufferSubData *cmd);
+
 void GLAPIENTRY
 _mesa_marshal_BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
                             const GLvoid * data);
@@ -197,6 +209,10 @@ void GLAPIENTRY
 _mesa_marshal_NamedBufferSubData(GLuint buffer, GLintptr offset, GLsizeiptr size,
                                  const GLvoid * data);
 
+void GLAPIENTRY
+_mesa_marshal_NamedBufferSubDataEXT(GLuint buffer, GLintptr offset,
+                                    GLsizeiptr size, const GLvoid * data);
+
 static inline unsigned
 _mesa_buffer_enum_to_count(GLenum buffer)
 {