glthread: move buffer functions into glthread_bufferobj.c
[mesa.git] / src / mesa / main / marshal.c
index 14577dd4cb4ed39231a285b0603eff5fd7114eb2..a6610095783a3510cf19b1f236215557785d9164 100644 (file)
  * thread when automatic code generation isn't appropriate.
  */
 
+#include "main/enums.h"
+#include "main/macros.h"
 #include "marshal.h"
 #include "dispatch.h"
-#include "marshal_generated.h"
-
-struct marshal_cmd_Flush
-{
-   struct marshal_cmd_base cmd_base;
-};
-
-
-void
-_mesa_unmarshal_Flush(struct gl_context *ctx,
-                      const struct marshal_cmd_Flush *cmd)
-{
-   CALL_Flush(ctx->CurrentServerDispatch, ());
-}
-
-
-void GLAPIENTRY
-_mesa_marshal_Flush(void)
-{
-   GET_CURRENT_CONTEXT(ctx);
-   struct marshal_cmd_Flush *cmd =
-      _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_Flush,
-                                      sizeof(struct marshal_cmd_Flush));
-   (void) cmd;
-   _mesa_post_marshal_hook(ctx);
-
-   /* Flush() needs to be handled specially.  In addition to telling the
-    * background thread to flush, we need to ensure that our own buffer is
-    * submitted to the background thread so that it will complete in a finite
-    * amount of time.
-    */
-   _mesa_glthread_flush_batch(ctx);
-}
-
 
 struct marshal_cmd_ShaderSource
 {
@@ -91,7 +59,7 @@ _mesa_unmarshal_ShaderSource(struct gl_context *ctx,
    }
    CALL_ShaderSource(ctx->CurrentServerDispatch,
                      (cmd->shader, cmd->count, string, cmd_length));
-   free(string);
+   free((void *)string);
 }
 
 
@@ -131,7 +99,7 @@ _mesa_marshal_ShaderSource(GLuint shader, GLsizei count,
       measure_ShaderSource_strings(count, string, length, length_tmp);
    size_t total_cmd_size = fixed_cmd_size + length_size + total_string_length;
 
-   if (total_cmd_size <= MARSHAL_MAX_CMD_SIZE) {
+   if (total_cmd_size <= MARSHAL_MAX_CMD_SIZE && count > 0) {
       struct marshal_cmd_ShaderSource *cmd =
          _mesa_glthread_allocate_command(ctx, DISPATCH_CMD_ShaderSource,
                                          total_cmd_size);
@@ -146,7 +114,6 @@ _mesa_marshal_ShaderSource(GLuint shader, GLsizei count,
          memcpy(cmd_strings, string[i], cmd_length[i]);
          cmd_strings += cmd_length[i];
       }
-      _mesa_post_marshal_hook(ctx);
    } else {
       _mesa_glthread_finish(ctx);
       CALL_ShaderSource(ctx->CurrentServerDispatch,