2 * Copyright © 2014 Broadcom
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:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29 #include "util/u_math.h"
31 #include "vc4_packet.h"
43 void vc4_init_cl(struct vc4_context
*vc4
, struct vc4_cl
*cl
);
44 void vc4_reset_cl(struct vc4_cl
*cl
);
45 void vc4_dump_cl(void *cl
, uint32_t size
, bool is_render
);
46 uint32_t vc4_gem_hindex(struct vc4_context
*vc4
, struct vc4_bo
*bo
);
49 cl_u8(struct vc4_cl
*cl
, uint8_t n
)
51 assert((cl
->next
- cl
->base
) + 1 <= cl
->size
);
53 *(uint8_t *)cl
->next
= n
;
58 cl_u16(struct vc4_cl
*cl
, uint16_t n
)
60 assert((cl
->next
- cl
->base
) + 2 <= cl
->size
);
62 *(uint16_t *)cl
->next
= n
;
67 cl_u32(struct vc4_cl
*cl
, uint32_t n
)
69 assert((cl
->next
- cl
->base
) + 4 <= cl
->size
);
71 *(uint32_t *)cl
->next
= n
;
76 cl_ptr(struct vc4_cl
*cl
, void *ptr
)
78 assert((cl
->next
- cl
->base
) + sizeof(void *) <= cl
->size
);
80 *(void **)cl
->next
= ptr
;
81 cl
->next
+= sizeof(void *);
85 cl_f(struct vc4_cl
*cl
, float f
)
91 cl_start_reloc(struct vc4_cl
*cl
, uint32_t n
)
93 assert(n
== 1 || n
== 2);
94 assert(cl
->reloc_count
== 0);
97 cl_u8(cl
, VC4_PACKET_GEM_HANDLES
);
98 cl
->reloc_next
= cl
->next
- cl
->base
;
99 cl_u32(cl
, 0); /* Space where hindex will be written. */
100 cl_u32(cl
, 0); /* Space where hindex will be written. */
104 cl_start_shader_reloc(struct vc4_cl
*cl
, uint32_t n
)
106 assert(cl
->reloc_count
== 0);
108 cl
->reloc_next
= cl
->next
- cl
->base
;
110 /* Space where hindex will be written. */
115 cl_reloc_hindex(struct vc4_cl
*cl
, uint32_t hindex
, uint32_t offset
)
117 *(uint32_t *)(cl
->base
+ cl
->reloc_next
) = hindex
;
126 cl_reloc(struct vc4_context
*vc4
, struct vc4_cl
*cl
,
127 struct vc4_bo
*bo
, uint32_t offset
)
129 cl_reloc_hindex(cl
, vc4_gem_hindex(vc4
, bo
), offset
);
132 void cl_ensure_space(struct vc4_cl
*cl
, uint32_t size
);
134 #endif /* VC4_CL_H */