2 * Mesa 3-D graphics library
4 * Copyright (C) 2012-2013 LunarG, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Chia-I Wu <olv@lunarg.com>
31 #include "core/ilo_builder.h"
32 #include "core/intel_winsys.h"
34 #include "ilo_common.h"
37 struct ilo_shader_cache
;
39 typedef void (*ilo_cp_callback
)(struct ilo_cp
*cp
, void *data
);
42 * Parser owners are notified when they gain or lose the ownership of the
43 * parser. This gives owners a chance to emit prolog or epilog.
47 ilo_cp_callback release
;
51 * Space reserved for release(). This can be modified at any time, as long
52 * as it is never increased by more than ilo_cp_space().
61 struct intel_winsys
*winsys
;
62 struct ilo_shader_cache
*shader_cache
;
63 struct intel_context
*render_ctx
;
65 ilo_cp_callback submit_callback
;
66 void *submit_callback_data
;
68 enum intel_ring_type ring
;
69 const struct ilo_cp_owner
*owner
;
71 unsigned one_off_flags
;
73 struct ilo_builder builder
;
74 struct intel_bo
*last_submitted_bo
;
77 uint32_t pending_lost
;
81 ilo_cp_create(const struct ilo_dev
*dev
,
82 struct intel_winsys
*winsys
,
83 struct ilo_shader_cache
*shc
);
86 ilo_cp_destroy(struct ilo_cp
*cp
);
89 ilo_cp_submit_internal(struct ilo_cp
*cp
);
92 ilo_cp_submit(struct ilo_cp
*cp
, const char *reason
)
94 if (ilo_debug
& ILO_DEBUG_SUBMIT
) {
95 ilo_printf("submit batch buffer to %s ring because of %s: ",
96 (cp
->ring
== INTEL_RING_RENDER
) ? "render" : "unknown", reason
);
97 ilo_builder_batch_print_stats(&cp
->builder
);
100 ilo_cp_submit_internal(cp
);
104 ilo_cp_set_owner(struct ilo_cp
*cp
, enum intel_ring_type ring
,
105 const struct ilo_cp_owner
*owner
);
108 * Return the remaining space (in dwords) in the parser buffer.
111 ilo_cp_space(struct ilo_cp
*cp
)
113 const int space
= ilo_builder_batch_space(&cp
->builder
);
114 const int mi_batch_buffer_end_space
= 2;
116 assert(space
>= cp
->owner
->reserve
+ mi_batch_buffer_end_space
);
118 return space
- cp
->owner
->reserve
- mi_batch_buffer_end_space
;
122 * Set one-off flags. They will be cleared after submission.
125 ilo_cp_set_one_off_flags(struct ilo_cp
*cp
, unsigned flags
)
127 cp
->one_off_flags
|= flags
;
131 * Set submit callback. The callback is invoked after the bo has been
132 * successfully submitted, and before the bo is reallocated.
135 ilo_cp_set_submit_callback(struct ilo_cp
*cp
, ilo_cp_callback callback
,
138 cp
->submit_callback
= callback
;
139 cp
->submit_callback_data
= data
;
142 #endif /* ILO_CP_H */