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_grow_cl(struct vc4_cl
*cl
);
45 void vc4_reset_cl(struct vc4_cl
*cl
);
46 void vc4_dump_cl(void *cl
, uint32_t size
, bool is_render
);
47 uint32_t vc4_gem_hindex(struct vc4_context
*vc4
, struct vc4_bo
*bo
);
50 cl_u8(struct vc4_cl
*cl
, uint8_t n
)
52 if (cl
->next
+ 1 > cl
->end
)
55 *(uint8_t *)cl
->next
= n
;
60 cl_u16(struct vc4_cl
*cl
, uint32_t n
)
62 if (cl
->next
+ 2 > cl
->end
)
65 *(uint16_t *)cl
->next
= n
;
70 cl_u32(struct vc4_cl
*cl
, uint32_t n
)
72 if (cl
->next
+ 4 > cl
->end
)
75 *(uint32_t *)cl
->next
= n
;
80 cl_ptr(struct vc4_cl
*cl
, void *ptr
)
82 if (cl
->next
+ sizeof(void *) > cl
->end
)
85 *(void **)cl
->next
= ptr
;
86 cl
->next
+= sizeof(void *);
90 cl_f(struct vc4_cl
*cl
, float f
)
96 cl_start_reloc(struct vc4_cl
*cl
, uint32_t n
)
98 assert(n
== 1 || n
== 2);
99 assert(cl
->reloc_count
== 0);
102 cl_u8(cl
, VC4_PACKET_GEM_HANDLES
);
103 cl
->reloc_next
= cl
->next
- cl
->base
;
104 cl_u32(cl
, 0); /* Space where hindex will be written. */
105 cl_u32(cl
, 0); /* Space where hindex will be written. */
109 cl_start_shader_reloc(struct vc4_cl
*cl
, uint32_t n
)
111 assert(cl
->reloc_count
== 0);
113 cl
->reloc_next
= cl
->next
- cl
->base
;
115 for (int i
= 0; i
< n
; i
++)
116 cl_u32(cl
, 0); /* Space where hindex will be written. */
120 cl_reloc(struct vc4_context
*vc4
, struct vc4_cl
*cl
,
121 struct vc4_bo
*bo
, uint32_t offset
)
123 *(uint32_t *)(cl
->base
+ cl
->reloc_next
) = vc4_gem_hindex(vc4
, bo
);
131 #endif /* VC4_CL_H */