blob: e29eec9315c2bb81ebf588c0db9003412f8d5132 [file] [log] [blame]
Chia-I Wu00a23b22014-08-20 15:28:08 +08001/*
2 * XGL
3 *
4 * Copyright (C) 2014 LunarG, Inc.
5 *
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:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
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.
Chia-I Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wu00a23b22014-08-20 15:28:08 +080026 */
27
28#ifndef CMD_PRIV_H
29#define CMD_PRIV_H
30
Chia-I Wue24c3292014-08-21 14:05:23 +080031#include "genhw/genhw.h"
Chia-I Wu32710d72014-08-20 16:05:22 +080032#include "dev.h"
33#include "gpu.h"
Chia-I Wu00a23b22014-08-20 15:28:08 +080034#include "cmd.h"
35
Chia-I Wu32710d72014-08-20 16:05:22 +080036#define CMD_ASSERT(cmd, min_gen, max_gen) \
37 INTEL_GPU_ASSERT((cmd)->dev->gpu, (min_gen), (max_gen))
38
Chia-I Wu00b51a82014-09-09 12:07:37 +080039enum intel_cmd_item_type {
40 /* for state buffer */
41 INTEL_CMD_ITEM_BLOB,
42 INTEL_CMD_ITEM_CLIP_VIEWPORT,
43 INTEL_CMD_ITEM_SF_VIEWPORT,
44 INTEL_CMD_ITEM_SCISSOR_RECT,
45 INTEL_CMD_ITEM_CC_VIEWPORT,
46 INTEL_CMD_ITEM_COLOR_CALC,
47 INTEL_CMD_ITEM_DEPTH_STENCIL,
48 INTEL_CMD_ITEM_BLEND,
49 INTEL_CMD_ITEM_SAMPLER,
50
51 /* for surface buffer */
52 INTEL_CMD_ITEM_SURFACE,
53 INTEL_CMD_ITEM_BINDING_TABLE,
54
55 /* for instruction buffer */
56 INTEL_CMD_ITEM_KERNEL,
57
58 INTEL_CMD_ITEM_COUNT,
59};
60
61struct intel_cmd_item {
62 enum intel_cmd_item_type type;
63 XGL_SIZE offset;
64 XGL_SIZE size;
65};
66
Chia-I Wud7d1e482014-10-18 13:25:10 +080067#define INTEL_CMD_RELOC_TARGET_IS_WRITER (1u << 31)
Chia-I Wu958d1b72014-08-21 11:28:11 +080068struct intel_cmd_reloc {
Chia-I Wu68f319d2014-09-09 09:43:21 +080069 enum intel_cmd_writer_type which;
Chia-I Wu72292b72014-09-09 10:48:33 +080070 XGL_SIZE offset;
Chia-I Wu958d1b72014-08-21 11:28:11 +080071
Chia-I Wud7d1e482014-10-18 13:25:10 +080072 intptr_t target;
73 uint32_t target_offset;
Chia-I Wu958d1b72014-08-21 11:28:11 +080074
Chia-I Wu32a22462014-08-26 14:13:46 +080075 uint32_t flags;
Chia-I Wu958d1b72014-08-21 11:28:11 +080076};
77
Chia-I Wuc14d1562014-10-17 09:49:22 +080078struct intel_ds_view;
79
Chia-I Wu29e6f502014-11-24 14:27:29 +080080enum intel_cmd_meta_mode {
81 /*
Chia-I Wu4d344e62014-12-20 21:06:04 +080082 * Draw POINTLIST of (width * height) vertices with only VS enabled. The
83 * vertex id is from 0 to (width * height - 1).
Chia-I Wu29e6f502014-11-24 14:27:29 +080084 */
85 INTEL_CMD_META_VS_POINTS,
86
87 /*
88 * Draw a RECTLIST from (dst.x, dst.y) to (dst.x + width, dst.y + height)
89 * with only FS enabled.
90 */
91 INTEL_CMD_META_FS_RECT,
92
93 /*
94 * Draw a RECTLIST from (dst.x, dst.y) to (dst.x + width, dst.y + height)
95 * with only depth/stencil enabled.
96 */
97 INTEL_CMD_META_DEPTH_STENCIL_RECT,
98};
99
Chia-I Wuc14d1562014-10-17 09:49:22 +0800100struct intel_cmd_meta {
Chia-I Wu29e6f502014-11-24 14:27:29 +0800101 enum intel_cmd_meta_mode mode;
Chia-I Wuc14d1562014-10-17 09:49:22 +0800102 enum intel_dev_meta_shader shader_id;
103
104 struct {
105 bool valid;
106
107 uint32_t surface[8];
108 XGL_UINT surface_len;
109
110 intptr_t reloc_target;
111 uint32_t reloc_offset;
112 uint32_t reloc_flags;
113
114 XGL_UINT lod, layer;
115 XGL_UINT x, y;
116 } src, dst;
117
Chia-I Wu429a0aa2014-10-24 11:57:51 +0800118 struct {
119 struct intel_ds_view *view;
120 struct intel_ds_state *state;
121 } ds;
122
Chia-I Wuc14d1562014-10-17 09:49:22 +0800123 uint32_t clear_val[4];
124
125 XGL_UINT width, height;
126 XGL_UINT samples;
127};
128
Chia-I Wu9f039862014-08-20 15:39:56 +0800129static inline int cmd_gen(const struct intel_cmd *cmd)
130{
131 return intel_gpu_gen(cmd->dev->gpu);
132}
133
Chia-I Wucdff0592014-08-22 09:27:36 +0800134static inline void cmd_reserve_reloc(struct intel_cmd *cmd,
135 XGL_UINT reloc_len)
136{
137 /* fail silently */
138 if (cmd->reloc_used + reloc_len > cmd->reloc_count) {
139 cmd->reloc_used = 0;
140 cmd->result = XGL_ERROR_TOO_MANY_MEMORY_REFERENCES;
141 }
142 assert(cmd->reloc_used + reloc_len <= cmd->reloc_count);
143}
144
Chia-I Wue24c3292014-08-21 14:05:23 +0800145void cmd_writer_grow(struct intel_cmd *cmd,
Chia-I Wu3c3edc02014-09-09 10:32:59 +0800146 enum intel_cmd_writer_type which,
Chia-I Wu72292b72014-09-09 10:48:33 +0800147 XGL_SIZE new_size);
148
Chia-I Wu00b51a82014-09-09 12:07:37 +0800149void cmd_writer_record(struct intel_cmd *cmd,
150 enum intel_cmd_writer_type which,
151 enum intel_cmd_item_type type,
152 XGL_SIZE offset, XGL_SIZE size);
153
Chia-I Wu72292b72014-09-09 10:48:33 +0800154/**
155 * Return an offset to a region that is aligned to \p alignment and has at
156 * least \p size bytes.
157 */
158static inline XGL_SIZE cmd_writer_reserve(struct intel_cmd *cmd,
159 enum intel_cmd_writer_type which,
160 XGL_SIZE alignment, XGL_SIZE size)
161{
162 struct intel_cmd_writer *writer = &cmd->writers[which];
163 XGL_SIZE offset;
164
165 assert(alignment && u_is_pow2(alignment));
166 offset = u_align(writer->used, alignment);
167
168 if (offset + size > writer->size) {
169 cmd_writer_grow(cmd, which, offset + size);
170 /* align again in case of errors */
171 offset = u_align(writer->used, alignment);
172
173 assert(offset + size <= writer->size);
174 }
175
176 return offset;
177}
Chia-I Wu00a23b22014-08-20 15:28:08 +0800178
Chia-I Wu32710d72014-08-20 16:05:22 +0800179/**
Chia-I Wubda55fd2014-08-25 12:46:10 +0800180 * Add a reloc at \p pos. No error checking.
Chia-I Wucdff0592014-08-22 09:27:36 +0800181 */
Chia-I Wu72292b72014-09-09 10:48:33 +0800182static inline void cmd_writer_reloc(struct intel_cmd *cmd,
183 enum intel_cmd_writer_type which,
Chia-I Wud7d1e482014-10-18 13:25:10 +0800184 XGL_SIZE offset, intptr_t target,
185 uint32_t target_offset, uint32_t flags)
Chia-I Wucdff0592014-08-22 09:27:36 +0800186{
187 struct intel_cmd_reloc *reloc = &cmd->relocs[cmd->reloc_used];
188
189 assert(cmd->reloc_used < cmd->reloc_count);
190
Chia-I Wu68f319d2014-09-09 09:43:21 +0800191 reloc->which = which;
Chia-I Wu72292b72014-09-09 10:48:33 +0800192 reloc->offset = offset;
Chia-I Wud7d1e482014-10-18 13:25:10 +0800193 reloc->target = target;
194 reloc->target_offset = target_offset;
Chia-I Wu32a22462014-08-26 14:13:46 +0800195 reloc->flags = flags;
Chia-I Wucdff0592014-08-22 09:27:36 +0800196
197 cmd->reloc_used++;
198}
199
200/**
Chia-I Wu5da476a2014-12-10 08:50:28 +0800201 * Reserve a region from the state buffer. The offset, in bytes, to the
202 * reserved region is returned.
Chia-I Wu72292b72014-09-09 10:48:33 +0800203 *
204 * Note that \p alignment is in bytes and \p len is in DWords.
Chia-I Wue24c3292014-08-21 14:05:23 +0800205 */
Chia-I Wu5da476a2014-12-10 08:50:28 +0800206static inline uint32_t cmd_state_reserve(struct intel_cmd *cmd,
Chia-I Wu00b51a82014-09-09 12:07:37 +0800207 enum intel_cmd_item_type item,
Chia-I Wu5da476a2014-12-10 08:50:28 +0800208 XGL_SIZE alignment, XGL_UINT len)
Chia-I Wue24c3292014-08-21 14:05:23 +0800209{
Chia-I Wu72292b72014-09-09 10:48:33 +0800210 const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_STATE;
211 const XGL_SIZE size = len << 2;
212 const XGL_SIZE offset = cmd_writer_reserve(cmd, which, alignment, size);
213 struct intel_cmd_writer *writer = &cmd->writers[which];
Chia-I Wue24c3292014-08-21 14:05:23 +0800214
Chia-I Wu72292b72014-09-09 10:48:33 +0800215 /* all states are at least aligned to 32-bytes */
216 assert(alignment % 32 == 0);
217
Chia-I Wu72292b72014-09-09 10:48:33 +0800218 writer->used = offset + size;
219
Chia-I Wu00b51a82014-09-09 12:07:37 +0800220 if (intel_debug & INTEL_DEBUG_BATCH)
221 cmd_writer_record(cmd, which, item, offset, size);
222
Chia-I Wu72292b72014-09-09 10:48:33 +0800223 return offset;
Chia-I Wue24c3292014-08-21 14:05:23 +0800224}
225
226/**
Chia-I Wu5da476a2014-12-10 08:50:28 +0800227 * Get the pointer to a reserved region for updating. The pointer is only
228 * valid until the next reserve call.
229 */
230static inline void cmd_state_update(struct intel_cmd *cmd,
231 uint32_t offset, XGL_UINT len,
232 uint32_t **dw)
233{
234 const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_STATE;
235 struct intel_cmd_writer *writer = &cmd->writers[which];
236
237 assert(offset + (len << 2) <= writer->used);
238
239 *dw = (uint32_t *) ((char *) writer->ptr + offset);
240}
241
242/**
243 * Reserve a region from the state buffer. Both the offset, in bytes, and the
244 * pointer to the reserved region are returned. The pointer is only valid
245 * until the next reserve call.
246 *
247 * Note that \p alignment is in bytes and \p len is in DWords.
248 */
249static inline uint32_t cmd_state_pointer(struct intel_cmd *cmd,
250 enum intel_cmd_item_type item,
251 XGL_SIZE alignment, XGL_UINT len,
252 uint32_t **dw)
253{
254 const uint32_t offset = cmd_state_reserve(cmd, item, alignment, len);
255
256 cmd_state_update(cmd, offset, len, dw);
257
258 return offset;
259}
260
261/**
Chia-I Wu72292b72014-09-09 10:48:33 +0800262 * Write a dynamic state to the state buffer.
Chia-I Wucdff0592014-08-22 09:27:36 +0800263 */
Chia-I Wu72292b72014-09-09 10:48:33 +0800264static inline uint32_t cmd_state_write(struct intel_cmd *cmd,
Chia-I Wu00b51a82014-09-09 12:07:37 +0800265 enum intel_cmd_item_type item,
Chia-I Wu72292b72014-09-09 10:48:33 +0800266 XGL_SIZE alignment, XGL_UINT len,
267 const uint32_t *dw)
Chia-I Wucdff0592014-08-22 09:27:36 +0800268{
Chia-I Wu72292b72014-09-09 10:48:33 +0800269 uint32_t offset, *dst;
270
Chia-I Wu00b51a82014-09-09 12:07:37 +0800271 offset = cmd_state_pointer(cmd, item, alignment, len, &dst);
Chia-I Wu72292b72014-09-09 10:48:33 +0800272 memcpy(dst, dw, len << 2);
273
274 return offset;
Chia-I Wucdff0592014-08-22 09:27:36 +0800275}
276
277/**
Chia-I Wu72292b72014-09-09 10:48:33 +0800278 * Write a surface state to the surface buffer. The offset, in bytes, of the
279 * state is returned.
280 *
281 * Note that \p alignment is in bytes and \p len is in DWords.
Chia-I Wue24c3292014-08-21 14:05:23 +0800282 */
Chia-I Wu72292b72014-09-09 10:48:33 +0800283static inline uint32_t cmd_surface_write(struct intel_cmd *cmd,
Chia-I Wu00b51a82014-09-09 12:07:37 +0800284 enum intel_cmd_item_type item,
Chia-I Wu72292b72014-09-09 10:48:33 +0800285 XGL_SIZE alignment, XGL_UINT len,
286 const uint32_t *dw)
Chia-I Wue24c3292014-08-21 14:05:23 +0800287{
Chia-I Wu00b51a82014-09-09 12:07:37 +0800288 assert(item == INTEL_CMD_ITEM_SURFACE ||
289 item == INTEL_CMD_ITEM_BINDING_TABLE);
290
291 return cmd_state_write(cmd, item, alignment, len, dw);
Chia-I Wue24c3292014-08-21 14:05:23 +0800292}
293
294/**
Chia-I Wu72292b72014-09-09 10:48:33 +0800295 * Add a relocation entry for a DWord of a surface state.
Chia-I Wucdff0592014-08-22 09:27:36 +0800296 */
Chia-I Wu72292b72014-09-09 10:48:33 +0800297static inline void cmd_surface_reloc(struct intel_cmd *cmd,
298 uint32_t offset, XGL_UINT dw_index,
299 struct intel_bo *bo,
300 uint32_t bo_offset, uint32_t reloc_flags)
Chia-I Wucdff0592014-08-22 09:27:36 +0800301{
Chia-I Wu72292b72014-09-09 10:48:33 +0800302 const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_STATE;
Chia-I Wucdff0592014-08-22 09:27:36 +0800303
Chia-I Wu72292b72014-09-09 10:48:33 +0800304 cmd_writer_reloc(cmd, which, offset + (dw_index << 2),
Chia-I Wud7d1e482014-10-18 13:25:10 +0800305 (intptr_t) bo, bo_offset, reloc_flags);
306}
307
308static inline void cmd_surface_reloc_writer(struct intel_cmd *cmd,
309 uint32_t offset, XGL_UINT dw_index,
310 enum intel_cmd_writer_type writer,
311 uint32_t writer_offset)
312{
313 const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_STATE;
314
315 cmd_writer_reloc(cmd, which, offset + (dw_index << 2),
316 (intptr_t) writer, writer_offset,
317 INTEL_CMD_RELOC_TARGET_IS_WRITER);
Chia-I Wucdff0592014-08-22 09:27:36 +0800318}
319
320/**
Chia-I Wu72292b72014-09-09 10:48:33 +0800321 * Write a kernel to the instruction buffer. The offset, in bytes, of the
322 * kernel is returned.
Chia-I Wue24c3292014-08-21 14:05:23 +0800323 */
Chia-I Wu72292b72014-09-09 10:48:33 +0800324static inline uint32_t cmd_instruction_write(struct intel_cmd *cmd,
325 XGL_SIZE size,
326 const void *kernel)
Chia-I Wue24c3292014-08-21 14:05:23 +0800327{
Chia-I Wu72292b72014-09-09 10:48:33 +0800328 const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_INSTRUCTION;
329 /*
330 * From the Sandy Bridge PRM, volume 4 part 2, page 112:
331 *
332 * "Due to prefetch of the instruction stream, the EUs may attempt to
333 * access up to 8 instructions (128 bytes) beyond the end of the
334 * kernel program - possibly into the next memory page. Although
335 * these instructions will not be executed, software must account for
336 * the prefetch in order to avoid invalid page access faults."
337 */
338 const XGL_SIZE reserved_size = size + 128;
339 /* kernels are aligned to 64 bytes */
340 const XGL_SIZE alignment = 64;
341 const XGL_SIZE offset = cmd_writer_reserve(cmd,
342 which, alignment, reserved_size);
343 struct intel_cmd_writer *writer = &cmd->writers[which];
Chia-I Wue24c3292014-08-21 14:05:23 +0800344
Chia-I Wu72292b72014-09-09 10:48:33 +0800345 memcpy((char *) writer->ptr + offset, kernel, size);
Chia-I Wu5e25c272014-08-21 20:19:12 +0800346
Chia-I Wu72292b72014-09-09 10:48:33 +0800347 writer->used = offset + size;
348
Chia-I Wu00b51a82014-09-09 12:07:37 +0800349 if (intel_debug & INTEL_DEBUG_BATCH)
350 cmd_writer_record(cmd, which, INTEL_CMD_ITEM_KERNEL, offset, size);
351
Chia-I Wu72292b72014-09-09 10:48:33 +0800352 return offset;
353}
354
355/**
356 * Reserve a region from the batch buffer. Both the offset, in DWords, and
Chia-I Wu5da476a2014-12-10 08:50:28 +0800357 * the pointer to the reserved region are returned. The pointer is only valid
358 * until the next reserve call.
Chia-I Wu72292b72014-09-09 10:48:33 +0800359 *
360 * Note that \p len is in DWords.
361 */
362static inline XGL_UINT cmd_batch_pointer(struct intel_cmd *cmd,
363 XGL_UINT len, uint32_t **dw)
364{
365 const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_BATCH;
366 /*
367 * We know the batch bo is always aligned. Using 1 here should allow the
368 * compiler to optimize away aligning.
369 */
370 const XGL_SIZE alignment = 1;
371 const XGL_SIZE size = len << 2;
372 const XGL_SIZE offset = cmd_writer_reserve(cmd, which, alignment, size);
373 struct intel_cmd_writer *writer = &cmd->writers[which];
374
375 assert(offset % 4 == 0);
376 *dw = (uint32_t *) ((char *) writer->ptr + offset);
377
378 writer->used = offset + size;
379
380 return offset >> 2;
381}
382
383/**
384 * Write a command to the batch buffer.
385 */
386static inline XGL_UINT cmd_batch_write(struct intel_cmd *cmd,
387 XGL_UINT len, const uint32_t *dw)
388{
389 XGL_UINT pos;
390 uint32_t *dst;
391
392 pos = cmd_batch_pointer(cmd, len, &dst);
393 memcpy(dst, dw, len << 2);
394
395 return pos;
396}
397
398/**
399 * Add a relocation entry for a DWord of a command.
400 */
401static inline void cmd_batch_reloc(struct intel_cmd *cmd, XGL_UINT pos,
402 struct intel_bo *bo,
403 uint32_t bo_offset, uint32_t reloc_flags)
404{
405 const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_BATCH;
406
Chia-I Wud7d1e482014-10-18 13:25:10 +0800407 cmd_writer_reloc(cmd, which, pos << 2, (intptr_t) bo, bo_offset, reloc_flags);
408}
409
410static inline void cmd_batch_reloc_writer(struct intel_cmd *cmd, XGL_UINT pos,
411 enum intel_cmd_writer_type writer,
412 uint32_t writer_offset)
413{
414 const enum intel_cmd_writer_type which = INTEL_CMD_WRITER_BATCH;
415
416 cmd_writer_reloc(cmd, which, pos << 2, (intptr_t) writer, writer_offset,
417 INTEL_CMD_RELOC_TARGET_IS_WRITER);
Chia-I Wue24c3292014-08-21 14:05:23 +0800418}
419
420/**
Chia-I Wu48c283d2014-08-25 23:13:46 +0800421 * Begin the batch buffer.
Chia-I Wu79dfbb32014-08-25 12:19:02 +0800422 */
423static inline void cmd_batch_begin(struct intel_cmd *cmd)
424{
Chia-I Wu48c283d2014-08-25 23:13:46 +0800425 /* STATE_BASE_ADDRESS */
Chia-I Wu79dfbb32014-08-25 12:19:02 +0800426 const uint8_t cmd_len = 10;
Chia-I Wu426072d2014-08-26 14:31:55 +0800427 const uint32_t dw0 = GEN6_RENDER_CMD(COMMON, STATE_BASE_ADDRESS) |
Chia-I Wu79dfbb32014-08-25 12:19:02 +0800428 (cmd_len - 2);
Chia-I Wu72292b72014-09-09 10:48:33 +0800429 XGL_UINT pos;
430 uint32_t *dw;
Chia-I Wu79dfbb32014-08-25 12:19:02 +0800431
432 CMD_ASSERT(cmd, 6, 7.5);
433
Chia-I Wu72292b72014-09-09 10:48:33 +0800434 pos = cmd_batch_pointer(cmd, cmd_len, &dw);
Chia-I Wu79dfbb32014-08-25 12:19:02 +0800435
Chia-I Wu72292b72014-09-09 10:48:33 +0800436 dw[0] = dw0;
Chia-I Wu79dfbb32014-08-25 12:19:02 +0800437 /* start offsets */
Chia-I Wu72292b72014-09-09 10:48:33 +0800438 dw[1] = 1;
439 dw[2] = 1;
440 dw[3] = 1;
441 dw[4] = 1;
442 dw[5] = 1;
Chia-I Wu79dfbb32014-08-25 12:19:02 +0800443 /* end offsets */
Chia-I Wu72292b72014-09-09 10:48:33 +0800444 dw[6] = 1;
445 dw[7] = 1 + 0xfffff000;
446 dw[8] = 1 + 0xfffff000;
447 dw[9] = 1;
Chia-I Wud7d1e482014-10-18 13:25:10 +0800448
449 cmd_reserve_reloc(cmd, 3);
450 cmd_batch_reloc_writer(cmd, pos + 2, INTEL_CMD_WRITER_STATE, 1);
451 cmd_batch_reloc_writer(cmd, pos + 3, INTEL_CMD_WRITER_STATE, 1);
452 cmd_batch_reloc_writer(cmd, pos + 5, INTEL_CMD_WRITER_INSTRUCTION, 1);
Chia-I Wu79dfbb32014-08-25 12:19:02 +0800453}
454
455/**
Chia-I Wue24c3292014-08-21 14:05:23 +0800456 * End the batch buffer.
457 */
458static inline void cmd_batch_end(struct intel_cmd *cmd)
459{
Chia-I Wu68f319d2014-09-09 09:43:21 +0800460 struct intel_cmd_writer *writer = &cmd->writers[INTEL_CMD_WRITER_BATCH];
Chia-I Wu72292b72014-09-09 10:48:33 +0800461 uint32_t *dw;
Chia-I Wu79dfbb32014-08-25 12:19:02 +0800462
Chia-I Wu72292b72014-09-09 10:48:33 +0800463 if (writer->used & 0x7) {
464 cmd_batch_pointer(cmd, 1, &dw);
465 dw[0] = GEN6_MI_CMD(MI_BATCH_BUFFER_END);
Chia-I Wue24c3292014-08-21 14:05:23 +0800466 } else {
Chia-I Wu72292b72014-09-09 10:48:33 +0800467 cmd_batch_pointer(cmd, 2, &dw);
468 dw[0] = GEN6_MI_CMD(MI_BATCH_BUFFER_END);
469 dw[1] = GEN6_MI_CMD(MI_NOOP);
Chia-I Wue24c3292014-08-21 14:05:23 +0800470 }
Chia-I Wu343b1372014-08-20 16:39:20 +0800471}
472
Chia-I Wu525c6602014-08-27 10:22:34 +0800473void cmd_batch_flush(struct intel_cmd *cmd, uint32_t pipe_control_dw0);
Chia-I Wu3fb47ce2014-10-28 11:19:36 +0800474void cmd_batch_flush_all(struct intel_cmd *cmd);
Chia-I Wu525c6602014-08-27 10:22:34 +0800475
Chia-I Wu759fa2e2014-08-30 18:44:47 +0800476void cmd_batch_depth_count(struct intel_cmd *cmd,
477 struct intel_bo *bo,
478 XGL_GPU_SIZE offset);
479
Chia-I Wue8dbd5d2014-08-31 13:15:58 +0800480void cmd_batch_timestamp(struct intel_cmd *cmd,
481 struct intel_bo *bo,
482 XGL_GPU_SIZE offset);
483
484void cmd_batch_immediate(struct intel_cmd *cmd,
485 struct intel_bo *bo,
486 XGL_GPU_SIZE offset,
487 uint64_t val);
Chia-I Wu1cbc0052014-08-25 09:50:12 +0800488
Chia-I Wuc14d1562014-10-17 09:49:22 +0800489void cmd_draw_meta(struct intel_cmd *cmd, const struct intel_cmd_meta *meta);
490
Chia-I Wu00a23b22014-08-20 15:28:08 +0800491#endif /* CMD_PRIV_H */