radeonsi: don't crash if input_usage_mask is 0 for a VS input
[mesa.git] / src / gallium / drivers / lima / lima_draw.c
1 /*
2 * Copyright (c) 2011-2013 Luc Verhaegen <libv@skynet.be>
3 * Copyright (c) 2017-2019 Lima Project
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sub license,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
14 * 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 NON-INFRINGEMENT. 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.
23 *
24 */
25
26 #include "util/format/u_format.h"
27 #include "util/u_debug.h"
28 #include "util/u_half.h"
29 #include "util/u_helpers.h"
30 #include "util/u_inlines.h"
31 #include "util/u_pack_color.h"
32 #include "util/u_split_draw.h"
33 #include "util/u_upload_mgr.h"
34 #include "util/u_prim.h"
35 #include "util/u_vbuf.h"
36 #include "util/hash_table.h"
37
38 #include "lima_context.h"
39 #include "lima_screen.h"
40 #include "lima_resource.h"
41 #include "lima_program.h"
42 #include "lima_bo.h"
43 #include "lima_job.h"
44 #include "lima_texture.h"
45 #include "lima_util.h"
46 #include "lima_gpu.h"
47
48 #include "pan_minmax_cache.h"
49
50 #include <drm-uapi/lima_drm.h>
51
52 static void
53 lima_clip_scissor_to_viewport(struct lima_context *ctx)
54 {
55 struct lima_context_framebuffer *fb = &ctx->framebuffer;
56 struct pipe_scissor_state *cscissor = &ctx->clipped_scissor;
57 int viewport_left, viewport_right, viewport_bottom, viewport_top;
58
59 if (ctx->rasterizer && ctx->rasterizer->base.scissor) {
60 struct pipe_scissor_state *scissor = &ctx->scissor;
61 cscissor->minx = scissor->minx;
62 cscissor->maxx = scissor->maxx;
63 cscissor->miny = scissor->miny;
64 cscissor->maxy = scissor->maxy;
65 } else {
66 cscissor->minx = 0;
67 cscissor->maxx = fb->base.width;
68 cscissor->miny = 0;
69 cscissor->maxy = fb->base.height;
70 }
71
72 viewport_left = MAX2(ctx->viewport.left, 0);
73 cscissor->minx = MAX2(cscissor->minx, viewport_left);
74 viewport_right = MIN2(ctx->viewport.right, fb->base.width);
75 cscissor->maxx = MIN2(cscissor->maxx, viewport_right);
76 if (cscissor->minx > cscissor->maxx)
77 cscissor->minx = cscissor->maxx;
78
79 viewport_bottom = MAX2(ctx->viewport.bottom, 0);
80 cscissor->miny = MAX2(cscissor->miny, viewport_bottom);
81 viewport_top = MIN2(ctx->viewport.top, fb->base.height);
82 cscissor->maxy = MIN2(cscissor->maxy, viewport_top);
83 if (cscissor->miny > cscissor->maxy)
84 cscissor->miny = cscissor->maxy;
85 }
86
87 static bool
88 lima_is_scissor_zero(struct lima_context *ctx)
89 {
90 struct pipe_scissor_state *cscissor = &ctx->clipped_scissor;
91
92 return cscissor->minx == cscissor->maxx || cscissor->miny == cscissor->maxy;
93 }
94
95 static void
96 lima_update_job_wb(struct lima_context *ctx, unsigned buffers)
97 {
98 struct lima_job *job = lima_job_get(ctx);
99 struct lima_context_framebuffer *fb = &ctx->framebuffer;
100
101 /* add to job when the buffer is dirty and resolve is clear (not added before) */
102 if (fb->base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0) &&
103 !(job->resolve & PIPE_CLEAR_COLOR0)) {
104 struct lima_resource *res = lima_resource(fb->base.cbufs[0]->texture);
105 lima_flush_job_accessing_bo(ctx, res->bo, true);
106 _mesa_hash_table_insert(ctx->write_jobs, &res->base, job);
107 lima_job_add_bo(job, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
108 }
109
110 /* add to job when the buffer is dirty and resolve is clear (not added before) */
111 if (fb->base.zsbuf && (buffers & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)) &&
112 !(job->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
113 struct lima_resource *res = lima_resource(fb->base.zsbuf->texture);
114 lima_flush_job_accessing_bo(ctx, res->bo, true);
115 _mesa_hash_table_insert(ctx->write_jobs, &res->base, job);
116 lima_job_add_bo(job, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
117 }
118
119 job->resolve |= buffers;
120 }
121
122 static void
123 lima_damage_rect_union(struct pipe_scissor_state *rect,
124 unsigned minx, unsigned maxx,
125 unsigned miny, unsigned maxy)
126 {
127 rect->minx = MIN2(rect->minx, minx);
128 rect->miny = MIN2(rect->miny, miny);
129 rect->maxx = MAX2(rect->maxx, maxx);
130 rect->maxy = MAX2(rect->maxy, maxy);
131 }
132
133 static void
134 lima_clear(struct pipe_context *pctx, unsigned buffers, const struct pipe_scissor_state *scissor_state,
135 const union pipe_color_union *color, double depth, unsigned stencil)
136 {
137 struct lima_context *ctx = lima_context(pctx);
138 struct lima_job *job = lima_job_get(ctx);
139
140 /* flush if this job already contains any draw, otherwise multi clear can be
141 * combined into a single job */
142 if (lima_job_has_draw_pending(job)) {
143 lima_do_job(job);
144 job = lima_job_get(ctx);
145 }
146
147 lima_update_job_wb(ctx, buffers);
148
149 /* no need to reload if cleared */
150 if (ctx->framebuffer.base.nr_cbufs && (buffers & PIPE_CLEAR_COLOR0)) {
151 struct lima_surface *surf = lima_surface(ctx->framebuffer.base.cbufs[0]);
152 surf->reload &= ~PIPE_CLEAR_COLOR0;
153 }
154
155 struct lima_job_clear *clear = &job->clear;
156 clear->buffers = buffers;
157
158 if (buffers & PIPE_CLEAR_COLOR0) {
159 clear->color_8pc =
160 ((uint32_t)float_to_ubyte(color->f[3]) << 24) |
161 ((uint32_t)float_to_ubyte(color->f[2]) << 16) |
162 ((uint32_t)float_to_ubyte(color->f[1]) << 8) |
163 float_to_ubyte(color->f[0]);
164
165 clear->color_16pc =
166 ((uint64_t)float_to_ushort(color->f[3]) << 48) |
167 ((uint64_t)float_to_ushort(color->f[2]) << 32) |
168 ((uint64_t)float_to_ushort(color->f[1]) << 16) |
169 float_to_ushort(color->f[0]);
170 }
171
172 struct lima_surface *zsbuf = lima_surface(ctx->framebuffer.base.zsbuf);
173
174 if (buffers & PIPE_CLEAR_DEPTH) {
175 clear->depth = util_pack_z(PIPE_FORMAT_Z24X8_UNORM, depth);
176 if (zsbuf)
177 zsbuf->reload &= ~PIPE_CLEAR_DEPTH;
178 } else
179 clear->depth = 0x00ffffff;
180
181 if (buffers & PIPE_CLEAR_STENCIL) {
182 clear->stencil = stencil;
183 if (zsbuf)
184 zsbuf->reload &= ~PIPE_CLEAR_STENCIL;
185 }
186
187 ctx->dirty |= LIMA_CONTEXT_DIRTY_CLEAR;
188
189 lima_damage_rect_union(&job->damage_rect,
190 0, ctx->framebuffer.base.width,
191 0, ctx->framebuffer.base.height);
192 }
193
194 enum lima_attrib_type {
195 LIMA_ATTRIB_FLOAT = 0x000,
196 /* todo: find out what lives here. */
197 LIMA_ATTRIB_I16 = 0x004,
198 LIMA_ATTRIB_U16 = 0x005,
199 LIMA_ATTRIB_I8 = 0x006,
200 LIMA_ATTRIB_U8 = 0x007,
201 LIMA_ATTRIB_I8N = 0x008,
202 LIMA_ATTRIB_U8N = 0x009,
203 LIMA_ATTRIB_I16N = 0x00A,
204 LIMA_ATTRIB_U16N = 0x00B,
205 /* todo: where is the 32 int */
206 /* todo: find out what lives here. */
207 LIMA_ATTRIB_FIXED = 0x101
208 };
209
210 static enum lima_attrib_type
211 lima_pipe_format_to_attrib_type(enum pipe_format format)
212 {
213 const struct util_format_description *desc = util_format_description(format);
214 int i = util_format_get_first_non_void_channel(format);
215 const struct util_format_channel_description *c = desc->channel + i;
216
217 switch (c->type) {
218 case UTIL_FORMAT_TYPE_FLOAT:
219 return LIMA_ATTRIB_FLOAT;
220 case UTIL_FORMAT_TYPE_FIXED:
221 return LIMA_ATTRIB_FIXED;
222 case UTIL_FORMAT_TYPE_SIGNED:
223 if (c->size == 8) {
224 if (c->normalized)
225 return LIMA_ATTRIB_I8N;
226 else
227 return LIMA_ATTRIB_I8;
228 }
229 else if (c->size == 16) {
230 if (c->normalized)
231 return LIMA_ATTRIB_I16N;
232 else
233 return LIMA_ATTRIB_I16;
234 }
235 break;
236 case UTIL_FORMAT_TYPE_UNSIGNED:
237 if (c->size == 8) {
238 if (c->normalized)
239 return LIMA_ATTRIB_U8N;
240 else
241 return LIMA_ATTRIB_U8;
242 }
243 else if (c->size == 16) {
244 if (c->normalized)
245 return LIMA_ATTRIB_U16N;
246 else
247 return LIMA_ATTRIB_U16;
248 }
249 break;
250 }
251
252 return LIMA_ATTRIB_FLOAT;
253 }
254
255 static void
256 lima_pack_vs_cmd(struct lima_context *ctx, const struct pipe_draw_info *info)
257 {
258 struct lima_job *job = lima_job_get(ctx);
259
260 VS_CMD_BEGIN(&job->vs_cmd_array, 24);
261
262 if (!info->index_size) {
263 VS_CMD_ARRAYS_SEMAPHORE_BEGIN_1();
264 VS_CMD_ARRAYS_SEMAPHORE_BEGIN_2();
265 }
266
267 int uniform_size = ctx->vs->uniform_pending_offset + ctx->vs->constant_size + 32;
268 VS_CMD_UNIFORMS_ADDRESS(
269 lima_ctx_buff_va(ctx, lima_ctx_buff_gp_uniform),
270 align(uniform_size, 16));
271
272 VS_CMD_SHADER_ADDRESS(ctx->vs->bo->va, ctx->vs->shader_size);
273 VS_CMD_SHADER_INFO(ctx->vs->prefetch, ctx->vs->shader_size);
274
275 int num_outputs = ctx->vs->num_outputs;
276 int num_attributes = ctx->vertex_elements->num_elements;
277 VS_CMD_VARYING_ATTRIBUTE_COUNT(num_outputs, MAX2(1, num_attributes));
278
279 VS_CMD_UNKNOWN1();
280
281 VS_CMD_ATTRIBUTES_ADDRESS(
282 lima_ctx_buff_va(ctx, lima_ctx_buff_gp_attribute_info),
283 MAX2(1, num_attributes));
284
285 VS_CMD_VARYINGS_ADDRESS(
286 lima_ctx_buff_va(ctx, lima_ctx_buff_gp_varying_info),
287 num_outputs);
288
289 unsigned num = info->index_size ? (ctx->max_index - ctx->min_index + 1) : info->count;
290 VS_CMD_DRAW(num, info->index_size);
291
292 VS_CMD_UNKNOWN2();
293
294 VS_CMD_ARRAYS_SEMAPHORE_END(info->index_size);
295
296 VS_CMD_END();
297 }
298
299 static void
300 lima_pack_plbu_cmd(struct lima_context *ctx, const struct pipe_draw_info *info)
301 {
302 struct lima_vs_shader_state *vs = ctx->vs;
303 struct pipe_scissor_state *cscissor = &ctx->clipped_scissor;
304 struct lima_job *job = lima_job_get(ctx);
305 PLBU_CMD_BEGIN(&job->plbu_cmd_array, 32);
306
307 PLBU_CMD_VIEWPORT_LEFT(fui(ctx->viewport.left));
308 PLBU_CMD_VIEWPORT_RIGHT(fui(ctx->viewport.right));
309 PLBU_CMD_VIEWPORT_BOTTOM(fui(ctx->viewport.bottom));
310 PLBU_CMD_VIEWPORT_TOP(fui(ctx->viewport.top));
311
312 if (!info->index_size)
313 PLBU_CMD_ARRAYS_SEMAPHORE_BEGIN();
314
315 int cf = ctx->rasterizer->base.cull_face;
316 int ccw = ctx->rasterizer->base.front_ccw;
317 uint32_t cull = 0;
318 bool force_point_size = false;
319
320 if (cf != PIPE_FACE_NONE) {
321 if (cf & PIPE_FACE_FRONT)
322 cull |= ccw ? 0x00040000 : 0x00020000;
323 if (cf & PIPE_FACE_BACK)
324 cull |= ccw ? 0x00020000 : 0x00040000;
325 }
326
327 /* Specify point size with PLBU command if shader doesn't write */
328 if (info->mode == PIPE_PRIM_POINTS && ctx->vs->point_size_idx == -1)
329 force_point_size = true;
330
331 /* Specify line width with PLBU command for lines */
332 if (info->mode > PIPE_PRIM_POINTS && info->mode < PIPE_PRIM_TRIANGLES)
333 force_point_size = true;
334
335 PLBU_CMD_PRIMITIVE_SETUP(force_point_size, cull, info->index_size);
336
337 PLBU_CMD_RSW_VERTEX_ARRAY(
338 lima_ctx_buff_va(ctx, lima_ctx_buff_pp_plb_rsw),
339 ctx->gp_output->va);
340
341 /* TODO
342 * - we should set it only for the first draw that enabled the scissor and for
343 * latter draw only if scissor is dirty
344 */
345
346 assert(cscissor->minx < cscissor->maxx && cscissor->miny < cscissor->maxy);
347 PLBU_CMD_SCISSORS(cscissor->minx, cscissor->maxx, cscissor->miny, cscissor->maxy);
348
349 lima_damage_rect_union(&job->damage_rect, cscissor->minx, cscissor->maxx,
350 cscissor->miny, cscissor->maxy);
351
352 PLBU_CMD_UNKNOWN1();
353
354 PLBU_CMD_DEPTH_RANGE_NEAR(fui(ctx->viewport.near));
355 PLBU_CMD_DEPTH_RANGE_FAR(fui(ctx->viewport.far));
356
357 if ((info->mode == PIPE_PRIM_POINTS && ctx->vs->point_size_idx == -1) ||
358 ((info->mode >= PIPE_PRIM_LINES) && (info->mode < PIPE_PRIM_TRIANGLES)))
359 {
360 uint32_t v = info->mode == PIPE_PRIM_POINTS ?
361 fui(ctx->rasterizer->base.point_size) : fui(ctx->rasterizer->base.line_width);
362 PLBU_CMD_LOW_PRIM_SIZE(v);
363 }
364
365 if (info->index_size) {
366 PLBU_CMD_INDEXED_DEST(ctx->gp_output->va);
367 if (vs->point_size_idx != -1)
368 PLBU_CMD_INDEXED_PT_SIZE(ctx->gp_output->va + ctx->gp_output_point_size_offt);
369
370 PLBU_CMD_INDICES(ctx->index_res->bo->va + info->start * info->index_size + ctx->index_offset);
371 }
372 else {
373 /* can this make the attribute info static? */
374 PLBU_CMD_DRAW_ARRAYS(info->mode, info->start, info->count);
375 }
376
377 PLBU_CMD_ARRAYS_SEMAPHORE_END();
378
379 if (info->index_size)
380 PLBU_CMD_DRAW_ELEMENTS(info->mode, ctx->min_index, info->count);
381
382 PLBU_CMD_END();
383 }
384
385 static int
386 lima_blend_func(enum pipe_blend_func pipe)
387 {
388 switch (pipe) {
389 case PIPE_BLEND_ADD:
390 return 2;
391 case PIPE_BLEND_SUBTRACT:
392 return 0;
393 case PIPE_BLEND_REVERSE_SUBTRACT:
394 return 1;
395 case PIPE_BLEND_MIN:
396 return 4;
397 case PIPE_BLEND_MAX:
398 return 5;
399 }
400 return -1;
401 }
402
403 static int
404 lima_blend_factor_has_alpha(enum pipe_blendfactor pipe)
405 {
406 /* Bit 4 is set if the blendfactor uses alpha */
407 switch (pipe) {
408 case PIPE_BLENDFACTOR_SRC_ALPHA:
409 case PIPE_BLENDFACTOR_DST_ALPHA:
410 case PIPE_BLENDFACTOR_CONST_ALPHA:
411 case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
412 case PIPE_BLENDFACTOR_INV_DST_ALPHA:
413 case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
414 return 1;
415
416 case PIPE_BLENDFACTOR_SRC_COLOR:
417 case PIPE_BLENDFACTOR_INV_SRC_COLOR:
418 case PIPE_BLENDFACTOR_DST_COLOR:
419 case PIPE_BLENDFACTOR_INV_DST_COLOR:
420 case PIPE_BLENDFACTOR_CONST_COLOR:
421 case PIPE_BLENDFACTOR_INV_CONST_COLOR:
422 case PIPE_BLENDFACTOR_ZERO:
423 case PIPE_BLENDFACTOR_ONE:
424 case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
425 return 0;
426
427 case PIPE_BLENDFACTOR_SRC1_COLOR:
428 case PIPE_BLENDFACTOR_SRC1_ALPHA:
429 case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
430 case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
431 return -1; /* not supported */
432 }
433 return -1;
434 }
435
436 static int
437 lima_blend_factor_is_inv(enum pipe_blendfactor pipe)
438 {
439 /* Bit 3 is set if the blendfactor type is inverted */
440 switch (pipe) {
441 case PIPE_BLENDFACTOR_INV_SRC_COLOR:
442 case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
443 case PIPE_BLENDFACTOR_INV_DST_COLOR:
444 case PIPE_BLENDFACTOR_INV_DST_ALPHA:
445 case PIPE_BLENDFACTOR_INV_CONST_COLOR:
446 case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
447 case PIPE_BLENDFACTOR_ONE:
448 return 1;
449
450 case PIPE_BLENDFACTOR_SRC_COLOR:
451 case PIPE_BLENDFACTOR_SRC_ALPHA:
452 case PIPE_BLENDFACTOR_DST_COLOR:
453 case PIPE_BLENDFACTOR_DST_ALPHA:
454 case PIPE_BLENDFACTOR_CONST_COLOR:
455 case PIPE_BLENDFACTOR_CONST_ALPHA:
456 case PIPE_BLENDFACTOR_ZERO:
457 case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
458 return 0;
459
460 case PIPE_BLENDFACTOR_SRC1_COLOR:
461 case PIPE_BLENDFACTOR_SRC1_ALPHA:
462 case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
463 case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
464 return -1; /* not supported */
465 }
466 return -1;
467 }
468
469 static int
470 lima_blend_factor(enum pipe_blendfactor pipe)
471 {
472 /* Bits 0-2 indicate the blendfactor type */
473 switch (pipe) {
474 case PIPE_BLENDFACTOR_SRC_COLOR:
475 case PIPE_BLENDFACTOR_SRC_ALPHA:
476 case PIPE_BLENDFACTOR_INV_SRC_COLOR:
477 case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
478 return 0;
479
480 case PIPE_BLENDFACTOR_DST_COLOR:
481 case PIPE_BLENDFACTOR_DST_ALPHA:
482 case PIPE_BLENDFACTOR_INV_DST_COLOR:
483 case PIPE_BLENDFACTOR_INV_DST_ALPHA:
484 return 1;
485
486 case PIPE_BLENDFACTOR_CONST_COLOR:
487 case PIPE_BLENDFACTOR_CONST_ALPHA:
488 case PIPE_BLENDFACTOR_INV_CONST_COLOR:
489 case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
490 return 2;
491
492 case PIPE_BLENDFACTOR_ZERO:
493 case PIPE_BLENDFACTOR_ONE:
494 return 3;
495
496 case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
497 return 4;
498
499 case PIPE_BLENDFACTOR_SRC1_COLOR:
500 case PIPE_BLENDFACTOR_SRC1_ALPHA:
501 case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
502 case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
503 return -1; /* not supported */
504 }
505 return -1;
506 }
507
508 static int
509 lima_calculate_alpha_blend(enum pipe_blend_func rgb_func, enum pipe_blend_func alpha_func,
510 enum pipe_blendfactor rgb_src_factor, enum pipe_blendfactor rgb_dst_factor,
511 enum pipe_blendfactor alpha_src_factor, enum pipe_blendfactor alpha_dst_factor)
512 {
513 /* PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE has to be changed to PIPE_BLENDFACTOR_ONE
514 * if it is set for alpha_src.
515 */
516 if (alpha_src_factor == PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE)
517 alpha_src_factor = PIPE_BLENDFACTOR_ONE;
518
519 return lima_blend_func(rgb_func) |
520 (lima_blend_func(alpha_func) << 3) |
521
522 (lima_blend_factor(rgb_src_factor) << 6) |
523 (lima_blend_factor_is_inv(rgb_src_factor) << 9) |
524 (lima_blend_factor_has_alpha(rgb_src_factor) << 10) |
525
526 (lima_blend_factor(rgb_dst_factor) << 11) |
527 (lima_blend_factor_is_inv(rgb_dst_factor) << 14) |
528 (lima_blend_factor_has_alpha(rgb_dst_factor) << 15) |
529
530 (lima_blend_factor(alpha_src_factor) << 16) |
531 (lima_blend_factor_is_inv(alpha_src_factor) << 19) |
532
533 (lima_blend_factor(alpha_dst_factor) << 20) |
534 (lima_blend_factor_is_inv(alpha_dst_factor) << 23) |
535 0x0C000000; /* need to check if this is GLESv1 glAlphaFunc */
536 }
537
538 static int
539 lima_stencil_op(enum pipe_stencil_op pipe)
540 {
541 switch (pipe) {
542 case PIPE_STENCIL_OP_KEEP:
543 return 0;
544 case PIPE_STENCIL_OP_ZERO:
545 return 2;
546 case PIPE_STENCIL_OP_REPLACE:
547 return 1;
548 case PIPE_STENCIL_OP_INCR:
549 return 6;
550 case PIPE_STENCIL_OP_DECR:
551 return 7;
552 case PIPE_STENCIL_OP_INCR_WRAP:
553 return 4;
554 case PIPE_STENCIL_OP_DECR_WRAP:
555 return 5;
556 case PIPE_STENCIL_OP_INVERT:
557 return 3;
558 }
559 return -1;
560 }
561
562 static unsigned
563 lima_calculate_depth_test(struct pipe_depth_state *depth, struct pipe_rasterizer_state *rst)
564 {
565 int offset_scale = 0, offset_units = 0;
566 enum pipe_compare_func func = (depth->enabled ? depth->func : PIPE_FUNC_ALWAYS);
567
568 offset_scale = CLAMP(rst->offset_scale * 4, -128, 127);
569 if (offset_scale < 0)
570 offset_scale += 0x100;
571
572 offset_units = CLAMP(rst->offset_units * 2, -128, 127);
573 if (offset_units < 0)
574 offset_units += 0x100;
575
576 return (depth->enabled && depth->writemask) |
577 ((int)func << 1) |
578 (offset_scale << 16) |
579 (offset_units << 24) |
580 0x30; /* find out what is this */
581 }
582
583 static void
584 lima_pack_render_state(struct lima_context *ctx, const struct pipe_draw_info *info)
585 {
586 struct lima_fs_shader_state *fs = ctx->fs;
587 struct lima_render_state *render =
588 lima_ctx_buff_alloc(ctx, lima_ctx_buff_pp_plb_rsw,
589 sizeof(*render));
590 bool early_z = true;
591 bool pixel_kill = true;
592
593 /* do hw support RGBA independ blend?
594 * PIPE_CAP_INDEP_BLEND_ENABLE
595 *
596 * how to handle the no cbuf only zbuf case?
597 */
598 struct pipe_rt_blend_state *rt = ctx->blend->base.rt;
599 render->blend_color_bg = float_to_ubyte(ctx->blend_color.color[2]) |
600 (float_to_ubyte(ctx->blend_color.color[1]) << 16);
601 render->blend_color_ra = float_to_ubyte(ctx->blend_color.color[0]) |
602 (float_to_ubyte(ctx->blend_color.color[3]) << 16);
603
604 if (rt->blend_enable) {
605 render->alpha_blend = lima_calculate_alpha_blend(rt->rgb_func, rt->alpha_func,
606 rt->rgb_src_factor, rt->rgb_dst_factor,
607 rt->alpha_src_factor, rt->alpha_dst_factor);
608 }
609 else {
610 /*
611 * Special handling for blending disabled.
612 * Binary driver is generating the same alpha_value,
613 * as when we would just enable blending, without changing/setting any blend equation/params.
614 * Normaly in this case mesa would set all rt fields (func/factor) to zero.
615 */
616 render->alpha_blend = lima_calculate_alpha_blend(PIPE_BLEND_ADD, PIPE_BLEND_ADD,
617 PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ZERO,
618 PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ZERO);
619 }
620
621 render->alpha_blend |= (rt->colormask & PIPE_MASK_RGBA) << 28;
622
623 struct pipe_rasterizer_state *rst = &ctx->rasterizer->base;
624 struct pipe_depth_state *depth = &ctx->zsa->base.depth;
625 render->depth_test = lima_calculate_depth_test(depth, rst);
626
627 ushort far, near;
628
629 near = float_to_ushort(ctx->viewport.near);
630 far = float_to_ushort(ctx->viewport.far);
631
632 /* Subtract epsilon from 'near' if far == near. Make sure we don't get overflow */
633 if ((far == near) && (near != 0))
634 near--;
635
636 /* overlap with plbu? any place can remove one? */
637 render->depth_range = near | (far << 16);
638
639 struct pipe_stencil_state *stencil = ctx->zsa->base.stencil;
640 struct pipe_stencil_ref *ref = &ctx->stencil_ref;
641
642 if (stencil[0].enabled) { /* stencil is enabled */
643 render->stencil_front = stencil[0].func |
644 (lima_stencil_op(stencil[0].fail_op) << 3) |
645 (lima_stencil_op(stencil[0].zfail_op) << 6) |
646 (lima_stencil_op(stencil[0].zpass_op) << 9) |
647 (ref->ref_value[0] << 16) |
648 (stencil[0].valuemask << 24);
649 render->stencil_back = render->stencil_front;
650 render->stencil_test = (stencil[0].writemask & 0xff) | (stencil[0].writemask & 0xff) << 8;
651 if (stencil[1].enabled) { /* two-side is enabled */
652 render->stencil_back = stencil[1].func |
653 (lima_stencil_op(stencil[1].fail_op) << 3) |
654 (lima_stencil_op(stencil[1].zfail_op) << 6) |
655 (lima_stencil_op(stencil[1].zpass_op) << 9) |
656 (ref->ref_value[1] << 16) |
657 (stencil[1].valuemask << 24);
658 render->stencil_test = (stencil[0].writemask & 0xff) | (stencil[1].writemask & 0xff) << 8;
659 }
660 /* TODO: Find out, what (render->stecil_test & 0xffff0000) is.
661 * 0x00ff0000 is probably (float_to_ubyte(alpha->ref_value) << 16)
662 * (render->multi_sample & 0x00000007 is probably the compare function
663 * of glAlphaFunc then.
664 */
665 }
666 else {
667 /* Default values, when stencil is disabled:
668 * stencil[0|1].valuemask = 0xff
669 * stencil[0|1].func = PIPE_FUNC_ALWAYS
670 * stencil[0|1].writemask = 0xff
671 */
672 render->stencil_front = 0xff000007;
673 render->stencil_back = 0xff000007;
674 render->stencil_test = 0x0000ffff;
675 }
676
677 /* need more investigation */
678 if (info->mode == PIPE_PRIM_POINTS)
679 render->multi_sample = 0x0000F007;
680 else if (info->mode < PIPE_PRIM_TRIANGLES)
681 render->multi_sample = 0x0000F407;
682 else
683 render->multi_sample = 0x0000F807;
684 if (ctx->framebuffer.base.samples)
685 render->multi_sample |= 0x68;
686
687 render->shader_address =
688 ctx->fs->bo->va | (((uint32_t *)ctx->fs->bo->map)[0] & 0x1F);
689
690 /* seems not needed */
691 render->uniforms_address = 0x00000000;
692
693 render->textures_address = 0x00000000;
694
695 render->aux0 = (ctx->vs->varying_stride >> 3);
696 render->aux1 = 0x00001000;
697 if (ctx->blend->base.dither)
698 render->aux1 |= 0x00002000;
699
700 if (fs->uses_discard) {
701 early_z = false;
702 pixel_kill = false;
703 }
704
705 if (rt->blend_enable)
706 pixel_kill = false;
707
708 if ((rt->colormask & PIPE_MASK_RGBA) != PIPE_MASK_RGBA)
709 pixel_kill = false;
710
711 if (early_z)
712 render->aux0 |= 0x300;
713
714 if (pixel_kill)
715 render->aux0 |= 0x1000;
716
717 if (ctx->tex_stateobj.num_samplers) {
718 render->textures_address =
719 lima_ctx_buff_va(ctx, lima_ctx_buff_pp_tex_desc);
720 render->aux0 |= ctx->tex_stateobj.num_samplers << 14;
721 render->aux0 |= 0x20;
722 }
723
724 if (ctx->const_buffer[PIPE_SHADER_FRAGMENT].buffer) {
725 render->uniforms_address =
726 lima_ctx_buff_va(ctx, lima_ctx_buff_pp_uniform_array);
727 uint32_t size = ctx->buffer_state[lima_ctx_buff_pp_uniform].size;
728 uint32_t bits = 0;
729 if (size >= 8) {
730 bits = util_last_bit(size >> 3) - 1;
731 bits += size & u_bit_consecutive(0, bits + 3) ? 1 : 0;
732 }
733 render->uniforms_address |= bits > 0xf ? 0xf : bits;
734
735 render->aux0 |= 0x80;
736 render->aux1 |= 0x10000;
737 }
738
739 if (ctx->vs->num_varyings) {
740 render->varying_types = 0x00000000;
741 render->varyings_address = ctx->gp_output->va +
742 ctx->gp_output_varyings_offt;
743 for (int i = 0, index = 0; i < ctx->vs->num_outputs; i++) {
744 int val;
745
746 if (i == ctx->vs->gl_pos_idx ||
747 i == ctx->vs->point_size_idx)
748 continue;
749
750 struct lima_varying_info *v = ctx->vs->varying + i;
751 if (v->component_size == 4)
752 val = v->components > 2 ? 0 : 1;
753 else
754 val = v->components > 2 ? 2 : 3;
755
756 if (index < 10)
757 render->varying_types |= val << (3 * index);
758 else if (index == 10) {
759 render->varying_types |= val << 30;
760 render->varyings_address |= val >> 2;
761 }
762 else if (index == 11)
763 render->varyings_address |= val << 1;
764
765 index++;
766 }
767 }
768 else {
769 render->varying_types = 0x00000000;
770 render->varyings_address = 0x00000000;
771 }
772
773 struct lima_job *job = lima_job_get(ctx);
774
775 lima_dump_command_stream_print(
776 job->dump, render, sizeof(*render),
777 false, "add render state at va %x\n",
778 lima_ctx_buff_va(ctx, lima_ctx_buff_pp_plb_rsw));
779
780 lima_dump_rsw_command_stream_print(
781 job->dump, render, sizeof(*render),
782 lima_ctx_buff_va(ctx, lima_ctx_buff_pp_plb_rsw));
783 }
784
785 static void
786 lima_update_gp_attribute_info(struct lima_context *ctx, const struct pipe_draw_info *info)
787 {
788 struct lima_job *job = lima_job_get(ctx);
789 struct lima_vertex_element_state *ve = ctx->vertex_elements;
790 struct lima_context_vertex_buffer *vb = &ctx->vertex_buffers;
791
792 uint32_t *attribute =
793 lima_ctx_buff_alloc(ctx, lima_ctx_buff_gp_attribute_info,
794 MAX2(1, ve->num_elements) * 8);
795
796 int n = 0;
797 for (int i = 0; i < ve->num_elements; i++) {
798 struct pipe_vertex_element *pve = ve->pipe + i;
799
800 assert(pve->vertex_buffer_index < vb->count);
801 assert(vb->enabled_mask & (1 << pve->vertex_buffer_index));
802
803 struct pipe_vertex_buffer *pvb = vb->vb + pve->vertex_buffer_index;
804 struct lima_resource *res = lima_resource(pvb->buffer.resource);
805
806 lima_job_add_bo(job, LIMA_PIPE_GP, res->bo, LIMA_SUBMIT_BO_READ);
807
808 unsigned start = info->index_size ? (ctx->min_index + info->index_bias) : info->start;
809 attribute[n++] = res->bo->va + pvb->buffer_offset + pve->src_offset
810 + start * pvb->stride;
811 attribute[n++] = (pvb->stride << 11) |
812 (lima_pipe_format_to_attrib_type(pve->src_format) << 2) |
813 (util_format_get_nr_components(pve->src_format) - 1);
814 }
815
816 lima_dump_command_stream_print(
817 job->dump, attribute, n * 4, false, "update attribute info at va %x\n",
818 lima_ctx_buff_va(ctx, lima_ctx_buff_gp_attribute_info));
819 }
820
821 static void
822 lima_update_gp_uniform(struct lima_context *ctx)
823 {
824 struct lima_context_constant_buffer *ccb =
825 ctx->const_buffer + PIPE_SHADER_VERTEX;
826 struct lima_vs_shader_state *vs = ctx->vs;
827
828 int size = vs->uniform_pending_offset + vs->constant_size + 32;
829 void *vs_const_buff =
830 lima_ctx_buff_alloc(ctx, lima_ctx_buff_gp_uniform, size);
831
832 if (ccb->buffer)
833 memcpy(vs_const_buff, ccb->buffer, ccb->size);
834
835 memcpy(vs_const_buff + vs->uniform_pending_offset,
836 ctx->viewport.transform.scale,
837 sizeof(ctx->viewport.transform.scale));
838 memcpy(vs_const_buff + vs->uniform_pending_offset + 16,
839 ctx->viewport.transform.translate,
840 sizeof(ctx->viewport.transform.translate));
841
842 if (vs->constant)
843 memcpy(vs_const_buff + vs->uniform_pending_offset + 32,
844 vs->constant, vs->constant_size);
845
846 struct lima_job *job = lima_job_get(ctx);
847
848 if (lima_debug & LIMA_DEBUG_GP) {
849 float *vs_const_buff_f = vs_const_buff;
850 printf("gp uniforms:\n");
851 for (int i = 0; i < (size / sizeof(float)); i++) {
852 if ((i % 4) == 0)
853 printf("%4d:", i / 4);
854 printf(" %8.4f", vs_const_buff_f[i]);
855 if ((i % 4) == 3)
856 printf("\n");
857 }
858 printf("\n");
859 }
860
861 lima_dump_command_stream_print(
862 job->dump, vs_const_buff, size, true,
863 "update gp uniform at va %x\n",
864 lima_ctx_buff_va(ctx, lima_ctx_buff_gp_uniform));
865 }
866
867 static void
868 lima_update_pp_uniform(struct lima_context *ctx)
869 {
870 const float *const_buff = ctx->const_buffer[PIPE_SHADER_FRAGMENT].buffer;
871 size_t const_buff_size = ctx->const_buffer[PIPE_SHADER_FRAGMENT].size / sizeof(float);
872
873 if (!const_buff)
874 return;
875
876 uint16_t *fp16_const_buff =
877 lima_ctx_buff_alloc(ctx, lima_ctx_buff_pp_uniform,
878 const_buff_size * sizeof(uint16_t));
879
880 uint32_t *array =
881 lima_ctx_buff_alloc(ctx, lima_ctx_buff_pp_uniform_array, 4);
882
883 for (int i = 0; i < const_buff_size; i++)
884 fp16_const_buff[i] = util_float_to_half(const_buff[i]);
885
886 *array = lima_ctx_buff_va(ctx, lima_ctx_buff_pp_uniform);
887
888 struct lima_job *job = lima_job_get(ctx);
889
890 lima_dump_command_stream_print(
891 job->dump, fp16_const_buff, const_buff_size * 2,
892 false, "add pp uniform data at va %x\n",
893 lima_ctx_buff_va(ctx, lima_ctx_buff_pp_uniform));
894 lima_dump_command_stream_print(
895 job->dump, array, 4, false, "add pp uniform info at va %x\n",
896 lima_ctx_buff_va(ctx, lima_ctx_buff_pp_uniform_array));
897 }
898
899 static void
900 lima_update_varying(struct lima_context *ctx, const struct pipe_draw_info *info)
901 {
902 struct lima_job *job = lima_job_get(ctx);
903 struct lima_screen *screen = lima_screen(ctx->base.screen);
904 struct lima_vs_shader_state *vs = ctx->vs;
905 uint32_t gp_output_size;
906 unsigned num = info->index_size ? (ctx->max_index - ctx->min_index + 1) : info->count;
907
908 uint32_t *varying =
909 lima_ctx_buff_alloc(ctx, lima_ctx_buff_gp_varying_info,
910 vs->num_outputs * 8);
911 int n = 0;
912
913 int offset = 0;
914
915 for (int i = 0; i < vs->num_outputs; i++) {
916 struct lima_varying_info *v = vs->varying + i;
917
918 if (i == vs->gl_pos_idx ||
919 i == vs->point_size_idx)
920 continue;
921
922 int size = v->component_size * 4;
923
924 /* does component_size == 2 need to be 16 aligned? */
925 if (v->component_size == 4)
926 offset = align(offset, 16);
927
928 v->offset = offset;
929 offset += size;
930 }
931
932 vs->varying_stride = align(offset, 16);
933
934 /* gl_Position is always present, allocate space for it */
935 gp_output_size = align(4 * 4 * num, 0x40);
936
937 /* Allocate space for varyings if there're any */
938 if (vs->num_varyings) {
939 ctx->gp_output_varyings_offt = gp_output_size;
940 gp_output_size += align(vs->varying_stride * num, 0x40);
941 }
942
943 /* Allocate space for gl_PointSize if it's there */
944 if (vs->point_size_idx != -1) {
945 ctx->gp_output_point_size_offt = gp_output_size;
946 gp_output_size += 4 * num;
947 }
948
949 /* gp_output can be too large for the suballocator, so create a
950 * separate bo for it. The bo cache should prevent performance hit.
951 */
952 ctx->gp_output = lima_bo_create(screen, gp_output_size, 0);
953 assert(ctx->gp_output);
954 lima_job_add_bo(job, LIMA_PIPE_GP, ctx->gp_output, LIMA_SUBMIT_BO_WRITE);
955 lima_job_add_bo(job, LIMA_PIPE_PP, ctx->gp_output, LIMA_SUBMIT_BO_READ);
956
957 for (int i = 0; i < vs->num_outputs; i++) {
958 struct lima_varying_info *v = vs->varying + i;
959
960 if (i == vs->gl_pos_idx) {
961 /* gl_Position */
962 varying[n++] = ctx->gp_output->va;
963 varying[n++] = 0x8020;
964 } else if (i == vs->point_size_idx) {
965 /* gl_PointSize */
966 varying[n++] = ctx->gp_output->va + ctx->gp_output_point_size_offt;
967 varying[n++] = 0x2021;
968 } else {
969 /* Varying */
970 varying[n++] = ctx->gp_output->va + ctx->gp_output_varyings_offt +
971 v->offset;
972 varying[n++] = (vs->varying_stride << 11) | (v->components - 1) |
973 (v->component_size == 2 ? 0x0C : 0);
974 }
975 }
976
977 lima_dump_command_stream_print(
978 job->dump, varying, n * 4, false, "update varying info at va %x\n",
979 lima_ctx_buff_va(ctx, lima_ctx_buff_gp_varying_info));
980 }
981
982 static void
983 lima_draw_vbo_update(struct pipe_context *pctx,
984 const struct pipe_draw_info *info)
985 {
986 struct lima_context *ctx = lima_context(pctx);
987 struct lima_context_framebuffer *fb = &ctx->framebuffer;
988 unsigned buffers = 0;
989
990 if (fb->base.zsbuf) {
991 if (ctx->zsa->base.depth.enabled)
992 buffers |= PIPE_CLEAR_DEPTH;
993 if (ctx->zsa->base.stencil[0].enabled ||
994 ctx->zsa->base.stencil[1].enabled)
995 buffers |= PIPE_CLEAR_STENCIL;
996 }
997
998 if (fb->base.nr_cbufs)
999 buffers |= PIPE_CLEAR_COLOR0;
1000
1001 lima_update_job_wb(ctx, buffers);
1002
1003 lima_update_gp_attribute_info(ctx, info);
1004
1005 if ((ctx->dirty & LIMA_CONTEXT_DIRTY_CONST_BUFF &&
1006 ctx->const_buffer[PIPE_SHADER_VERTEX].dirty) ||
1007 ctx->dirty & LIMA_CONTEXT_DIRTY_VIEWPORT ||
1008 ctx->dirty & LIMA_CONTEXT_DIRTY_SHADER_VERT) {
1009 lima_update_gp_uniform(ctx);
1010 ctx->const_buffer[PIPE_SHADER_VERTEX].dirty = false;
1011 }
1012
1013 lima_update_varying(ctx, info);
1014
1015 lima_pack_vs_cmd(ctx, info);
1016
1017 if (ctx->dirty & LIMA_CONTEXT_DIRTY_CONST_BUFF &&
1018 ctx->const_buffer[PIPE_SHADER_FRAGMENT].dirty) {
1019 lima_update_pp_uniform(ctx);
1020 ctx->const_buffer[PIPE_SHADER_FRAGMENT].dirty = false;
1021 }
1022
1023 lima_update_textures(ctx);
1024
1025 lima_pack_render_state(ctx, info);
1026 lima_pack_plbu_cmd(ctx, info);
1027
1028 if (ctx->gp_output) {
1029 lima_bo_unreference(ctx->gp_output); /* held by job */
1030 ctx->gp_output = NULL;
1031 }
1032
1033 ctx->dirty = 0;
1034 }
1035
1036 static void
1037 lima_draw_vbo_indexed(struct pipe_context *pctx,
1038 const struct pipe_draw_info *info)
1039 {
1040 struct lima_context *ctx = lima_context(pctx);
1041 struct lima_job *job = lima_job_get(ctx);
1042 struct pipe_resource *indexbuf = NULL;
1043 bool needs_indices = true;
1044
1045 /* Mali Utgard GPU always need min/max index info for index draw,
1046 * compute it if upper layer does not do for us */
1047 if (info->max_index != ~0u) {
1048 ctx->min_index = info->min_index;
1049 ctx->max_index = info->max_index;
1050 needs_indices = false;
1051 }
1052
1053 if (info->has_user_indices) {
1054 util_upload_index_buffer(&ctx->base, info, &indexbuf, &ctx->index_offset, 0x40);
1055 ctx->index_res = lima_resource(indexbuf);
1056 }
1057 else {
1058 ctx->index_res = lima_resource(info->index.resource);
1059 ctx->index_offset = 0;
1060 needs_indices = !panfrost_minmax_cache_get(ctx->index_res->index_cache, info->start,
1061 info->count, &ctx->min_index, &ctx->max_index);
1062 }
1063
1064 if (needs_indices) {
1065 u_vbuf_get_minmax_index(pctx, info, &ctx->min_index, &ctx->max_index);
1066 if (!info->has_user_indices)
1067 panfrost_minmax_cache_add(ctx->index_res->index_cache, info->start, info->count,
1068 ctx->min_index, ctx->max_index);
1069 }
1070
1071 lima_job_add_bo(job, LIMA_PIPE_GP, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
1072 lima_job_add_bo(job, LIMA_PIPE_PP, ctx->index_res->bo, LIMA_SUBMIT_BO_READ);
1073 lima_draw_vbo_update(pctx, info);
1074
1075 if (indexbuf)
1076 pipe_resource_reference(&indexbuf, NULL);
1077 }
1078
1079 static void
1080 lima_draw_vbo_count(struct pipe_context *pctx,
1081 const struct pipe_draw_info *info)
1082 {
1083 static const uint32_t max_verts = 65535;
1084
1085 struct pipe_draw_info local_info = *info;
1086 unsigned start = info->start;
1087 unsigned count = info->count;
1088
1089 while (count) {
1090 unsigned this_count = count;
1091 unsigned step;
1092
1093 u_split_draw(info, max_verts, &this_count, &step);
1094
1095 local_info.start = start;
1096 local_info.count = this_count;
1097
1098 lima_draw_vbo_update(pctx, &local_info);
1099
1100 count -= step;
1101 start += step;
1102 }
1103 }
1104
1105 static void
1106 lima_draw_vbo(struct pipe_context *pctx,
1107 const struct pipe_draw_info *info)
1108 {
1109 /* check if draw mode and vertex/index count match,
1110 * otherwise gp will hang */
1111 if (!u_trim_pipe_prim(info->mode, (unsigned*)&info->count)) {
1112 debug_printf("draw mode and vertex/index count mismatch\n");
1113 return;
1114 }
1115
1116 struct lima_context *ctx = lima_context(pctx);
1117
1118 if (!ctx->vs || !ctx->fs) {
1119 debug_warn_once("no shader, skip draw\n");
1120 return;
1121 }
1122
1123 lima_clip_scissor_to_viewport(ctx);
1124 if (lima_is_scissor_zero(ctx))
1125 return;
1126
1127 if (!lima_update_vs_state(ctx) || !lima_update_fs_state(ctx))
1128 return;
1129
1130 struct lima_job *job = lima_job_get(ctx);
1131
1132 lima_dump_command_stream_print(
1133 job->dump, ctx->vs->bo->map, ctx->vs->shader_size, false,
1134 "add vs at va %x\n", ctx->vs->bo->va);
1135
1136 lima_dump_command_stream_print(
1137 job->dump, ctx->fs->bo->map, ctx->fs->shader_size, false,
1138 "add fs at va %x\n", ctx->fs->bo->va);
1139
1140 lima_job_add_bo(job, LIMA_PIPE_GP, ctx->vs->bo, LIMA_SUBMIT_BO_READ);
1141 lima_job_add_bo(job, LIMA_PIPE_PP, ctx->fs->bo, LIMA_SUBMIT_BO_READ);
1142
1143 if (info->index_size)
1144 lima_draw_vbo_indexed(pctx, info);
1145 else
1146 lima_draw_vbo_count(pctx, info);
1147 }
1148
1149 void
1150 lima_draw_init(struct lima_context *ctx)
1151 {
1152 ctx->base.clear = lima_clear;
1153 ctx->base.draw_vbo = lima_draw_vbo;
1154 }