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
27 #include "main/mtypes.h"
29 /* Command size is a number of bytes stored in a short. */
30 #define MARSHAL_MAX_CMD_SIZE 65535
32 /* The number of batch slots in memory.
34 * One batch is being executed, one batch is being filled, the rest are
35 * waiting batches. There must be at least 1 slot for a waiting batch,
36 * so the minimum number of batches is 3.
38 #define MARSHAL_MAX_BATCHES 4
43 #include "util/u_queue.h"
45 enum marshal_dispatch_cmd_id
;
47 /** A single batch of commands queued up for execution. */
50 /** Batch fence for waiting for the execution to finish. */
51 struct util_queue_fence fence
;
53 /** The worker thread will access the context with this. */
54 struct gl_context
*ctx
;
56 /** Amount of data used by batch commands, in bytes. */
59 /** Data contained in the command buffer. */
60 uint8_t buffer
[MARSHAL_MAX_CMD_SIZE
];
65 /** Multithreaded queue. */
66 struct util_queue queue
;
68 /** This is sent to the driver for framebuffer overlay / HUD. */
69 struct util_queue_monitoring stats
;
71 /** The ring of batches in memory. */
72 struct glthread_batch batches
[MARSHAL_MAX_BATCHES
];
74 /** Index of the last submitted batch. */
77 /** Index of the batch being filled and about to be submitted. */
81 * Tracks on the main thread side whether the current vertex array binding
84 bool vertex_array_is_vbo
;
87 * Tracks on the main thread side whether the current element array (index
88 * buffer) binding is in a VBO.
90 bool element_array_is_vbo
;
93 void _mesa_glthread_init(struct gl_context
*ctx
);
94 void _mesa_glthread_destroy(struct gl_context
*ctx
);
96 void _mesa_glthread_restore_dispatch(struct gl_context
*ctx
);
97 void _mesa_glthread_flush_batch(struct gl_context
*ctx
);
98 void _mesa_glthread_finish(struct gl_context
*ctx
);
100 #endif /* _GLTHREAD_H*/