1 /*
2 * Copyright (C) 2018-2019 Lima Project
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 *
22 */
23
24 #ifndef H_LIMA_JOB
25 #define H_LIMA_JOB
26
27 #include <stdbool.h>
28 #include <stdint.h>
29
30 #include <util/u_dynarray.h>
31
32 #include <pipe/p_state.h>
33
34 #define MAX_DRAWS_PER_JOB 2500
35
36 struct lima_context;
37 struct lima_bo;
38 struct lima_dump;
39 struct pipe_surface;
40
41 struct lima_job_key {
42 struct pipe_surface *cbuf;
43 struct pipe_surface *zsbuf;
44 };
45
46 struct lima_job_clear {
47 unsigned buffers;
48 uint32_t color_8pc;
49 uint32_t depth;
50 uint32_t stencil;
51 uint64_t color_16pc;
52 };
53
54 struct lima_job_fb_info {
55 int width, height;
56 int tiled_w, tiled_h;
57 int shift_w, shift_h;
58 int block_w, block_h;
59 int shift_min;
60 };
61
62 struct lima_job {
63 int fd;
64 struct lima_context *ctx;
65
66 struct util_dynarray gem_bos[2];
67 struct util_dynarray bos[2];
68
69 struct lima_job_key key;
70
71 struct util_dynarray vs_cmd_array;
72 struct util_dynarray plbu_cmd_array;
73 struct util_dynarray plbu_cmd_head;
74
75 unsigned resolve;
76
77 int pp_max_stack_size;
78
79 struct pipe_scissor_state damage_rect;
80
81 struct lima_job_clear clear;
82
83 struct lima_job_fb_info fb;
84
85 int draws;
86
87 /* for dump command stream */
88 struct lima_dump *dump;
89 };
90
91 static inline bool
lima_job_has_draw_pending(struct lima_job * job)92 lima_job_has_draw_pending(struct lima_job *job)
93 {
94 return !!job->plbu_cmd_array.size;
95 }
96
97 struct lima_job *lima_job_get(struct lima_context *ctx);
98 struct lima_job * lima_job_get_with_fb(struct lima_context *ctx,
99 struct pipe_surface *cbuf,
100 struct pipe_surface *zsbuf);
101
102 bool lima_job_add_bo(struct lima_job *job, int pipe,
103 struct lima_bo *bo, uint32_t flags);
104 void *lima_job_create_stream_bo(struct lima_job *job, int pipe,
105 unsigned size, uint32_t *va);
106
107 void lima_do_job(struct lima_job *job);
108
109 bool lima_job_init(struct lima_context *ctx);
110 void lima_job_fini(struct lima_context *ctx);
111
112 #endif
113