17ec681f3Smrg/*
27ec681f3Smrg * Copyright (C) 2018-2019 Lima Project
37ec681f3Smrg *
47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a
57ec681f3Smrg * copy of this software and associated documentation files (the "Software"),
67ec681f3Smrg * to deal in the Software without restriction, including without limitation
77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the
97ec681f3Smrg * Software is furnished to do so, subject to the following conditions:
107ec681f3Smrg *
117ec681f3Smrg * The above copyright notice and this permission notice shall be included in
127ec681f3Smrg * all copies or substantial portions of the Software.
137ec681f3Smrg *
147ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
157ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
167ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
177ec681f3Smrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
187ec681f3Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
197ec681f3Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
207ec681f3Smrg * OTHER DEALINGS IN THE SOFTWARE.
217ec681f3Smrg *
227ec681f3Smrg */
237ec681f3Smrg
247ec681f3Smrg#ifndef H_LIMA_JOB
257ec681f3Smrg#define H_LIMA_JOB
267ec681f3Smrg
277ec681f3Smrg#include <stdbool.h>
287ec681f3Smrg#include <stdint.h>
297ec681f3Smrg
307ec681f3Smrg#include <util/u_dynarray.h>
317ec681f3Smrg
327ec681f3Smrg#include <pipe/p_state.h>
337ec681f3Smrg
347ec681f3Smrg#define MAX_DRAWS_PER_JOB 2500
357ec681f3Smrg
367ec681f3Smrgstruct lima_context;
377ec681f3Smrgstruct lima_bo;
387ec681f3Smrgstruct lima_dump;
397ec681f3Smrgstruct pipe_surface;
407ec681f3Smrg
417ec681f3Smrgstruct lima_job_key {
427ec681f3Smrg   struct pipe_surface *cbuf;
437ec681f3Smrg   struct pipe_surface *zsbuf;
447ec681f3Smrg};
457ec681f3Smrg
467ec681f3Smrgstruct lima_job_clear {
477ec681f3Smrg   unsigned buffers;
487ec681f3Smrg   uint32_t color_8pc;
497ec681f3Smrg   uint32_t depth;
507ec681f3Smrg   uint32_t stencil;
517ec681f3Smrg   uint64_t color_16pc;
527ec681f3Smrg};
537ec681f3Smrg
547ec681f3Smrgstruct lima_job_fb_info {
557ec681f3Smrg   int width, height;
567ec681f3Smrg   int tiled_w, tiled_h;
577ec681f3Smrg   int shift_w, shift_h;
587ec681f3Smrg   int block_w, block_h;
597ec681f3Smrg   int shift_min;
607ec681f3Smrg};
617ec681f3Smrg
627ec681f3Smrgstruct lima_job {
637ec681f3Smrg   int fd;
647ec681f3Smrg   struct lima_context *ctx;
657ec681f3Smrg
667ec681f3Smrg   struct util_dynarray gem_bos[2];
677ec681f3Smrg   struct util_dynarray bos[2];
687ec681f3Smrg
697ec681f3Smrg   struct lima_job_key key;
707ec681f3Smrg
717ec681f3Smrg   struct util_dynarray vs_cmd_array;
727ec681f3Smrg   struct util_dynarray plbu_cmd_array;
737ec681f3Smrg   struct util_dynarray plbu_cmd_head;
747ec681f3Smrg
757ec681f3Smrg   unsigned resolve;
767ec681f3Smrg
777ec681f3Smrg   int pp_max_stack_size;
787ec681f3Smrg
797ec681f3Smrg   struct pipe_scissor_state damage_rect;
807ec681f3Smrg
817ec681f3Smrg   struct lima_job_clear clear;
827ec681f3Smrg
837ec681f3Smrg   struct lima_job_fb_info fb;
847ec681f3Smrg
857ec681f3Smrg   int draws;
867ec681f3Smrg
877ec681f3Smrg   /* for dump command stream */
887ec681f3Smrg   struct lima_dump *dump;
897ec681f3Smrg};
907ec681f3Smrg
917ec681f3Smrgstatic inline bool
927ec681f3Smrglima_job_has_draw_pending(struct lima_job *job)
937ec681f3Smrg{
947ec681f3Smrg   return !!job->plbu_cmd_array.size;
957ec681f3Smrg}
967ec681f3Smrg
977ec681f3Smrgstruct lima_job *lima_job_get(struct lima_context *ctx);
987ec681f3Smrg
997ec681f3Smrgbool lima_job_add_bo(struct lima_job *job, int pipe,
1007ec681f3Smrg                     struct lima_bo *bo, uint32_t flags);
1017ec681f3Smrgvoid *lima_job_create_stream_bo(struct lima_job *job, int pipe,
1027ec681f3Smrg                                unsigned size, uint32_t *va);
1037ec681f3Smrg
1047ec681f3Smrgvoid lima_do_job(struct lima_job *job);
1057ec681f3Smrg
1067ec681f3Smrgbool lima_job_init(struct lima_context *ctx);
1077ec681f3Smrgvoid lima_job_fini(struct lima_context *ctx);
1087ec681f3Smrg
1097ec681f3Smrg#endif
110