ad32b6b3f4df68fa8e0f8a704cc49101a8954a62
2 * Copyright © 2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 * Declarations of functions related to marshalling GL calls from a client
27 * thread to a server thread.
33 #include "main/glthread.h"
34 #include "main/context.h"
36 struct marshal_cmd_base
39 * Type of command. See enum marshal_dispatch_cmd_id.
44 * Size of command, in multiples of 4 bytes, including cmd_base.
51 _mesa_glthread_allocate_command(struct gl_context
*ctx
,
55 struct glthread_state
*glthread
= ctx
->GLThread
;
56 struct marshal_cmd_base
*cmd_base
;
58 if (unlikely(glthread
->batch
->used
+ size
> MARSHAL_MAX_CMD_SIZE
))
59 _mesa_glthread_flush_batch(ctx
);
61 cmd_base
= (struct marshal_cmd_base
*)
62 &glthread
->batch
->buffer
[glthread
->batch
->used
];
63 glthread
->batch
->used
+= size
;
64 cmd_base
->cmd_id
= cmd_id
;
65 cmd_base
->cmd_size
= size
;
69 #define DEBUG_MARSHAL_PRINT_CALLS 0
72 debug_print_sync(const char *func
)
74 #if DEBUG_MARSHAL_PRINT_CALLS
75 printf("sync: %s\n", func
);
80 debug_print_marshal(const char *func
)
82 #if DEBUG_MARSHAL_PRINT_CALLS
83 printf("marshal: %s\n", func
);
88 debug_print_unmarshal(const char *func
)
90 #if DEBUG_MARSHAL_PRINT_CALLS
91 printf("unmarshal: %s\n", func
);
96 _mesa_create_marshal_table(const struct gl_context
*ctx
);
99 _mesa_unmarshal_dispatch_cmd(struct gl_context
*ctx
, const void *cmd
);
102 _mesa_post_marshal_hook(struct gl_context
*ctx
)
104 /* This can be enabled for debugging whether a failure is a synchronization
105 * problem between the main thread and the worker thread, or a failure in
106 * how we actually marshal.
109 _mesa_glthread_finish(ctx
);
112 #endif /* MARSHAL_H */