Merge remote-tracking branch 'mesa-public/master' into vulkan
[mesa.git] / src / vulkan / anv_private.h
1 /*
2 * Copyright © 2015 Intel Corporation
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
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
21 * IN THE SOFTWARE.
22 */
23
24 #pragma once
25
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <stdbool.h>
29 #include <pthread.h>
30 #include <assert.h>
31 #include <i915_drm.h>
32
33 #ifdef HAVE_VALGRIND
34 #include <valgrind.h>
35 #include <memcheck.h>
36 #define VG(x) x
37 #define __gen_validate_value(x) VALGRIND_CHECK_MEM_IS_DEFINED(&(x), sizeof(x))
38 #else
39 #define VG(x)
40 #endif
41
42 #include "brw_device_info.h"
43 #include "util/macros.h"
44 #include "util/list.h"
45
46 #define VK_PROTOTYPES
47 #include <vulkan/vulkan.h>
48 #include <vulkan/vulkan_intel.h>
49 #include <vulkan/vk_wsi_lunarg.h>
50
51 #include "anv_entrypoints.h"
52
53 #include "brw_context.h"
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 #define anv_noreturn __attribute__((__noreturn__))
60 #define anv_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
61
62 #define MIN(a, b) ((a) < (b) ? (a) : (b))
63 #define MAX(a, b) ((a) > (b) ? (a) : (b))
64
65 static inline uint32_t
66 align_u32(uint32_t v, uint32_t a)
67 {
68 return (v + a - 1) & ~(a - 1);
69 }
70
71 static inline int32_t
72 align_i32(int32_t v, int32_t a)
73 {
74 return (v + a - 1) & ~(a - 1);
75 }
76
77 /** Alignment must be a power of 2. */
78 static inline bool
79 anv_is_aligned(uintmax_t n, uintmax_t a)
80 {
81 assert(a == (a & -a));
82 return (n & (a - 1)) == 0;
83 }
84
85 static inline uint32_t
86 anv_minify(uint32_t n, uint32_t levels)
87 {
88 if (unlikely(n == 0))
89 return 0;
90 else
91 return MAX(n >> levels, 1);
92 }
93
94 static inline bool
95 anv_clear_mask(uint32_t *inout_mask, uint32_t clear_mask)
96 {
97 if (*inout_mask & clear_mask) {
98 *inout_mask &= ~clear_mask;
99 return true;
100 } else {
101 return false;
102 }
103 }
104
105 #define for_each_bit(b, dword) \
106 for (uint32_t __dword = (dword); \
107 (b) = __builtin_ffs(__dword) - 1, __dword; \
108 __dword &= ~(1 << (b)))
109
110 /* Define no kernel as 1, since that's an illegal offset for a kernel */
111 #define NO_KERNEL 1
112
113 struct anv_common {
114 VkStructureType sType;
115 const void* pNext;
116 };
117
118 /* Whenever we generate an error, pass it through this function. Useful for
119 * debugging, where we can break on it. Only call at error site, not when
120 * propagating errors. Might be useful to plug in a stack trace here.
121 */
122
123 static inline VkResult
124 vk_error(VkResult error)
125 {
126 #ifdef DEBUG
127 fprintf(stderr, "vk_error: %x\n", error);
128 #endif
129
130 return error;
131 }
132
133 void __anv_finishme(const char *file, int line, const char *format, ...)
134 anv_printflike(3, 4);
135 void anv_loge(const char *format, ...) anv_printflike(1, 2);
136 void anv_loge_v(const char *format, va_list va);
137
138 /**
139 * Print a FINISHME message, including its source location.
140 */
141 #define anv_finishme(format, ...) \
142 __anv_finishme(__FILE__, __LINE__, format, ##__VA_ARGS__);
143
144 /* A non-fatal assert. Useful for debugging. */
145 #ifdef DEBUG
146 #define anv_assert(x) ({ \
147 if (unlikely(!(x))) \
148 fprintf(stderr, "%s:%d ASSERT: %s\n", __FILE__, __LINE__, #x); \
149 })
150 #else
151 #define anv_assert(x)
152 #endif
153
154 void anv_abortf(const char *format, ...) anv_noreturn anv_printflike(1, 2);
155 void anv_abortfv(const char *format, va_list va) anv_noreturn;
156
157 #define stub_return(v) \
158 do { \
159 anv_finishme("stub %s", __func__); \
160 return (v); \
161 } while (0)
162
163 #define stub() \
164 do { \
165 anv_finishme("stub %s", __func__); \
166 return; \
167 } while (0)
168
169 /**
170 * A dynamically growable, circular buffer. Elements are added at head and
171 * removed from tail. head and tail are free-running uint32_t indices and we
172 * only compute the modulo with size when accessing the array. This way,
173 * number of bytes in the queue is always head - tail, even in case of
174 * wraparound.
175 */
176
177 struct anv_vector {
178 uint32_t head;
179 uint32_t tail;
180 uint32_t element_size;
181 uint32_t size;
182 void *data;
183 };
184
185 int anv_vector_init(struct anv_vector *queue, uint32_t element_size, uint32_t size);
186 void *anv_vector_add(struct anv_vector *queue);
187 void *anv_vector_remove(struct anv_vector *queue);
188
189 static inline int
190 anv_vector_length(struct anv_vector *queue)
191 {
192 return (queue->head - queue->tail) / queue->element_size;
193 }
194
195 static inline void
196 anv_vector_finish(struct anv_vector *queue)
197 {
198 free(queue->data);
199 }
200
201 #define anv_vector_foreach(elem, queue) \
202 static_assert(__builtin_types_compatible_p(__typeof__(queue), struct anv_vector *), ""); \
203 for (uint32_t __anv_vector_offset = (queue)->tail; \
204 elem = (queue)->data + (__anv_vector_offset & ((queue)->size - 1)), __anv_vector_offset < (queue)->head; \
205 __anv_vector_offset += (queue)->element_size)
206
207 struct anv_bo {
208 int gem_handle;
209 uint32_t index;
210 uint64_t offset;
211 uint64_t size;
212 void *map;
213 };
214
215 /* Represents a lock-free linked list of "free" things. This is used by
216 * both the block pool and the state pools. Unfortunately, in order to
217 * solve the ABA problem, we can't use a single uint32_t head.
218 */
219 union anv_free_list {
220 struct {
221 uint32_t offset;
222
223 /* A simple count that is incremented every time the head changes. */
224 uint32_t count;
225 };
226 uint64_t u64;
227 };
228
229 #define ANV_FREE_LIST_EMPTY ((union anv_free_list) { { 1, 0 } })
230
231 struct anv_block_state {
232 union {
233 struct {
234 uint32_t next;
235 uint32_t end;
236 };
237 uint64_t u64;
238 };
239 };
240
241 struct anv_block_pool {
242 struct anv_device *device;
243
244 struct anv_bo bo;
245 void *map;
246 int fd;
247
248 /**
249 * Array of mmaps and gem handles owned by the block pool, reclaimed when
250 * the block pool is destroyed.
251 */
252 struct anv_vector mmap_cleanups;
253
254 uint32_t block_size;
255
256 union anv_free_list free_list;
257 struct anv_block_state state;
258 };
259
260 static inline uint32_t
261 anv_block_pool_size(struct anv_block_pool *pool)
262 {
263 return pool->state.end;
264 }
265
266 struct anv_state {
267 uint32_t offset;
268 uint32_t alloc_size;
269 void *map;
270 };
271
272 struct anv_fixed_size_state_pool {
273 size_t state_size;
274 union anv_free_list free_list;
275 struct anv_block_state block;
276 };
277
278 #define ANV_MIN_STATE_SIZE_LOG2 6
279 #define ANV_MAX_STATE_SIZE_LOG2 10
280
281 #define ANV_STATE_BUCKETS (ANV_MAX_STATE_SIZE_LOG2 - ANV_MIN_STATE_SIZE_LOG2)
282
283 struct anv_state_pool {
284 struct anv_block_pool *block_pool;
285 struct anv_fixed_size_state_pool buckets[ANV_STATE_BUCKETS];
286 };
287
288 struct anv_state_stream {
289 struct anv_block_pool *block_pool;
290 uint32_t next;
291 uint32_t current_block;
292 uint32_t end;
293 };
294
295 void anv_block_pool_init(struct anv_block_pool *pool,
296 struct anv_device *device, uint32_t block_size);
297 void anv_block_pool_finish(struct anv_block_pool *pool);
298 uint32_t anv_block_pool_alloc(struct anv_block_pool *pool);
299 void anv_block_pool_free(struct anv_block_pool *pool, uint32_t offset);
300 void anv_state_pool_init(struct anv_state_pool *pool,
301 struct anv_block_pool *block_pool);
302 void anv_state_pool_finish(struct anv_state_pool *pool);
303 struct anv_state anv_state_pool_alloc(struct anv_state_pool *pool,
304 size_t state_size, size_t alignment);
305 void anv_state_pool_free(struct anv_state_pool *pool, struct anv_state state);
306 void anv_state_stream_init(struct anv_state_stream *stream,
307 struct anv_block_pool *block_pool);
308 void anv_state_stream_finish(struct anv_state_stream *stream);
309 struct anv_state anv_state_stream_alloc(struct anv_state_stream *stream,
310 uint32_t size, uint32_t alignment);
311
312 /**
313 * Implements a pool of re-usable BOs. The interface is identical to that
314 * of block_pool except that each block is its own BO.
315 */
316 struct anv_bo_pool {
317 struct anv_device *device;
318
319 uint32_t bo_size;
320
321 void *free_list;
322 };
323
324 void anv_bo_pool_init(struct anv_bo_pool *pool,
325 struct anv_device *device, uint32_t block_size);
326 void anv_bo_pool_finish(struct anv_bo_pool *pool);
327 VkResult anv_bo_pool_alloc(struct anv_bo_pool *pool, struct anv_bo *bo);
328 void anv_bo_pool_free(struct anv_bo_pool *pool, const struct anv_bo *bo);
329
330 struct anv_physical_device {
331 struct anv_instance * instance;
332 uint32_t chipset_id;
333 const char * path;
334 const char * name;
335 const struct brw_device_info * info;
336 uint64_t aperture_size;
337 };
338
339 struct anv_instance {
340 void * pAllocUserData;
341 PFN_vkAllocFunction pfnAlloc;
342 PFN_vkFreeFunction pfnFree;
343 uint32_t apiVersion;
344 uint32_t physicalDeviceCount;
345 struct anv_physical_device physicalDevice;
346 };
347
348 struct anv_meta_state {
349 struct {
350 VkPipeline pipeline;
351 } clear;
352
353 struct {
354 VkPipeline pipeline;
355 VkPipelineLayout pipeline_layout;
356 VkDescriptorSetLayout ds_layout;
357 } blit;
358
359 struct {
360 VkDynamicRasterState rs_state;
361 VkDynamicColorBlendState cb_state;
362 VkDynamicDepthStencilState ds_state;
363 } shared;
364 };
365
366 struct anv_queue {
367 struct anv_device * device;
368
369 struct anv_state_pool * pool;
370
371 /**
372 * Serial number of the most recently completed batch executed on the
373 * engine.
374 */
375 struct anv_state completed_serial;
376
377 /**
378 * The next batch submitted to the engine will be assigned this serial
379 * number.
380 */
381 uint32_t next_serial;
382
383 uint32_t last_collected_serial;
384 };
385
386 struct anv_device {
387 struct anv_instance * instance;
388 uint32_t chipset_id;
389 struct brw_device_info info;
390 int context_id;
391 int fd;
392
393 struct anv_bo_pool batch_bo_pool;
394
395 struct anv_block_pool dynamic_state_block_pool;
396 struct anv_state_pool dynamic_state_pool;
397
398 struct anv_block_pool instruction_block_pool;
399 struct anv_block_pool surface_state_block_pool;
400 struct anv_state_pool surface_state_pool;
401
402 struct anv_meta_state meta_state;
403
404 struct anv_state border_colors;
405
406 struct anv_queue queue;
407
408 struct anv_block_pool scratch_block_pool;
409
410 struct anv_compiler * compiler;
411 pthread_mutex_t mutex;
412 };
413
414 void *
415 anv_device_alloc(struct anv_device * device,
416 size_t size,
417 size_t alignment,
418 VkSystemAllocType allocType);
419
420 void
421 anv_device_free(struct anv_device * device,
422 void * mem);
423
424 void* anv_gem_mmap(struct anv_device *device,
425 uint32_t gem_handle, uint64_t offset, uint64_t size);
426 void anv_gem_munmap(void *p, uint64_t size);
427 uint32_t anv_gem_create(struct anv_device *device, size_t size);
428 void anv_gem_close(struct anv_device *device, int gem_handle);
429 int anv_gem_userptr(struct anv_device *device, void *mem, size_t size);
430 int anv_gem_wait(struct anv_device *device, int gem_handle, int64_t *timeout_ns);
431 int anv_gem_execbuffer(struct anv_device *device,
432 struct drm_i915_gem_execbuffer2 *execbuf);
433 int anv_gem_set_tiling(struct anv_device *device, int gem_handle,
434 uint32_t stride, uint32_t tiling);
435 int anv_gem_create_context(struct anv_device *device);
436 int anv_gem_destroy_context(struct anv_device *device, int context);
437 int anv_gem_get_param(int fd, uint32_t param);
438 int anv_gem_get_aperture(int fd, uint64_t *size);
439 int anv_gem_handle_to_fd(struct anv_device *device, int gem_handle);
440 int anv_gem_fd_to_handle(struct anv_device *device, int fd);
441 int anv_gem_userptr(struct anv_device *device, void *mem, size_t size);
442
443 VkResult anv_bo_init_new(struct anv_bo *bo, struct anv_device *device, uint64_t size);
444
445 struct anv_reloc_list {
446 size_t num_relocs;
447 size_t array_length;
448 struct drm_i915_gem_relocation_entry * relocs;
449 struct anv_bo ** reloc_bos;
450 };
451
452 VkResult anv_reloc_list_init(struct anv_reloc_list *list,
453 struct anv_device *device);
454 void anv_reloc_list_finish(struct anv_reloc_list *list,
455 struct anv_device *device);
456
457 uint64_t anv_reloc_list_add(struct anv_reloc_list *list,
458 struct anv_device *device,
459 uint32_t offset, struct anv_bo *target_bo,
460 uint32_t delta);
461
462 struct anv_batch_bo {
463 /* Link in the anv_cmd_buffer.owned_batch_bos list */
464 struct list_head link;
465
466 struct anv_bo bo;
467
468 /* Bytes actually consumed in this batch BO */
469 size_t length;
470
471 struct anv_reloc_list relocs;
472 };
473
474 struct anv_batch {
475 struct anv_device * device;
476
477 void * start;
478 void * end;
479 void * next;
480
481 struct anv_reloc_list * relocs;
482
483 /* This callback is called (with the associated user data) in the event
484 * that the batch runs out of space.
485 */
486 VkResult (*extend_cb)(struct anv_batch *, void *);
487 void * user_data;
488 };
489
490 void *anv_batch_emit_dwords(struct anv_batch *batch, int num_dwords);
491 void anv_batch_emit_batch(struct anv_batch *batch, struct anv_batch *other);
492 uint64_t anv_batch_emit_reloc(struct anv_batch *batch,
493 void *location, struct anv_bo *bo, uint32_t offset);
494
495 struct anv_address {
496 struct anv_bo *bo;
497 uint32_t offset;
498 };
499
500 #define __gen_address_type struct anv_address
501 #define __gen_user_data struct anv_batch
502
503 static inline uint64_t
504 __gen_combine_address(struct anv_batch *batch, void *location,
505 const struct anv_address address, uint32_t delta)
506 {
507 if (address.bo == NULL) {
508 return delta;
509 } else {
510 assert(batch->start <= location && location < batch->end);
511
512 return anv_batch_emit_reloc(batch, location, address.bo, address.offset + delta);
513 }
514 }
515
516 #include "gen7_pack.h"
517 #include "gen75_pack.h"
518 #undef GEN8_3DSTATE_MULTISAMPLE
519 #include "gen8_pack.h"
520
521 #define anv_batch_emit(batch, cmd, ...) do { \
522 void *__dst = anv_batch_emit_dwords(batch, cmd ## _length); \
523 struct cmd __template = { \
524 cmd ## _header, \
525 __VA_ARGS__ \
526 }; \
527 cmd ## _pack(batch, __dst, &__template); \
528 VG(VALGRIND_CHECK_MEM_IS_DEFINED(__dst, cmd ## _length * 4)); \
529 } while (0)
530
531 #define anv_batch_emitn(batch, n, cmd, ...) ({ \
532 void *__dst = anv_batch_emit_dwords(batch, n); \
533 struct cmd __template = { \
534 cmd ## _header, \
535 .DwordLength = n - cmd ## _length_bias, \
536 __VA_ARGS__ \
537 }; \
538 cmd ## _pack(batch, __dst, &__template); \
539 __dst; \
540 })
541
542 #define anv_batch_emit_merge(batch, dwords0, dwords1) \
543 do { \
544 uint32_t *dw; \
545 \
546 assert(ARRAY_SIZE(dwords0) == ARRAY_SIZE(dwords1)); \
547 dw = anv_batch_emit_dwords((batch), ARRAY_SIZE(dwords0)); \
548 for (uint32_t i = 0; i < ARRAY_SIZE(dwords0); i++) \
549 dw[i] = (dwords0)[i] | (dwords1)[i]; \
550 VG(VALGRIND_CHECK_MEM_IS_DEFINED(dw, ARRAY_SIZE(dwords0) * 4));\
551 } while (0)
552
553 static const struct GEN7_MEMORY_OBJECT_CONTROL_STATE GEN7_MOCS = {
554 .GraphicsDataTypeGFDT = 0,
555 .LLCCacheabilityControlLLCCC = 0,
556 .L3CacheabilityControlL3CC = 1
557 };
558
559 #define GEN8_MOCS { \
560 .MemoryTypeLLCeLLCCacheabilityControl = WB, \
561 .TargetCache = L3DefertoPATforLLCeLLCselection, \
562 .AgeforQUADLRU = 0 \
563 }
564
565 struct anv_device_memory {
566 struct anv_bo bo;
567 VkDeviceSize map_size;
568 void * map;
569 };
570
571 struct anv_dynamic_vp_state {
572 struct anv_state sf_clip_vp;
573 struct anv_state cc_vp;
574 struct anv_state scissor;
575 };
576
577 struct anv_dynamic_rs_state {
578 struct {
579 uint32_t sf[GEN7_3DSTATE_SF_length];
580 } gen7;
581
582 struct {
583 uint32_t sf[GEN8_3DSTATE_SF_length];
584 uint32_t raster[GEN8_3DSTATE_RASTER_length];
585 } gen8;
586 };
587
588 struct anv_dynamic_ds_state {
589 struct {
590 uint32_t depth_stencil_state[GEN7_DEPTH_STENCIL_STATE_length];
591 uint32_t color_calc_state[GEN8_COLOR_CALC_STATE_length];
592 } gen7;
593
594 struct {
595 uint32_t wm_depth_stencil[GEN8_3DSTATE_WM_DEPTH_STENCIL_length];
596 uint32_t color_calc_state[GEN8_COLOR_CALC_STATE_length];
597 } gen8;
598 };
599
600 struct anv_dynamic_cb_state {
601 uint32_t color_calc_state[GEN8_COLOR_CALC_STATE_length];
602
603 };
604
605 struct anv_descriptor_slot {
606 int8_t dynamic_slot;
607 uint8_t index;
608 };
609
610 struct anv_descriptor_set_layout {
611 struct {
612 uint32_t surface_count;
613 struct anv_descriptor_slot *surface_start;
614 uint32_t sampler_count;
615 struct anv_descriptor_slot *sampler_start;
616 } stage[VK_SHADER_STAGE_NUM];
617
618 uint32_t count;
619 uint32_t num_dynamic_buffers;
620 uint32_t shader_stages;
621 struct anv_descriptor_slot entries[0];
622 };
623
624 struct anv_descriptor {
625 struct anv_sampler *sampler;
626 struct anv_surface_view *view;
627 };
628
629 struct anv_descriptor_set {
630 struct anv_descriptor descriptors[0];
631 };
632
633 VkResult
634 anv_descriptor_set_create(struct anv_device *device,
635 const struct anv_descriptor_set_layout *layout,
636 struct anv_descriptor_set **out_set);
637
638 void
639 anv_descriptor_set_destroy(struct anv_device *device,
640 struct anv_descriptor_set *set);
641
642 #define MAX_VBS 32
643 #define MAX_SETS 8
644 #define MAX_RTS 8
645
646 struct anv_pipeline_layout {
647 struct {
648 struct anv_descriptor_set_layout *layout;
649 uint32_t surface_start[VK_SHADER_STAGE_NUM];
650 uint32_t sampler_start[VK_SHADER_STAGE_NUM];
651 } set[MAX_SETS];
652
653 uint32_t num_sets;
654
655 struct {
656 uint32_t surface_count;
657 uint32_t sampler_count;
658 } stage[VK_SHADER_STAGE_NUM];
659 };
660
661 struct anv_buffer {
662 struct anv_device * device;
663 VkDeviceSize size;
664
665 /* Set when bound */
666 struct anv_bo * bo;
667 VkDeviceSize offset;
668 };
669
670 #define ANV_CMD_BUFFER_PIPELINE_DIRTY (1 << 0)
671 #define ANV_CMD_BUFFER_RS_DIRTY (1 << 2)
672 #define ANV_CMD_BUFFER_DS_DIRTY (1 << 3)
673 #define ANV_CMD_BUFFER_CB_DIRTY (1 << 4)
674 #define ANV_CMD_BUFFER_VP_DIRTY (1 << 5)
675 #define ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY (1 << 6)
676
677 struct anv_vertex_binding {
678 struct anv_buffer * buffer;
679 VkDeviceSize offset;
680 };
681
682 struct anv_descriptor_set_binding {
683 struct anv_descriptor_set * set;
684 uint32_t dynamic_offsets[128];
685 };
686
687 /** State required while building cmd buffer */
688 struct anv_cmd_state {
689 uint32_t current_pipeline;
690 uint32_t vb_dirty;
691 uint32_t dirty;
692 uint32_t compute_dirty;
693 uint32_t descriptors_dirty;
694 uint32_t scratch_size;
695 struct anv_pipeline * pipeline;
696 struct anv_pipeline * compute_pipeline;
697 struct anv_framebuffer * framebuffer;
698 struct anv_render_pass * pass;
699 struct anv_subpass * subpass;
700 struct anv_dynamic_rs_state * rs_state;
701 struct anv_dynamic_ds_state * ds_state;
702 struct anv_dynamic_vp_state * vp_state;
703 struct anv_dynamic_cb_state * cb_state;
704 uint32_t state_vf[GEN8_3DSTATE_VF_length];
705 struct anv_vertex_binding vertex_bindings[MAX_VBS];
706 struct anv_descriptor_set_binding descriptors[MAX_SETS];
707
708 struct {
709 struct anv_buffer * index_buffer;
710 uint32_t index_type;
711 uint32_t index_offset;
712 } gen7;
713 };
714
715 struct anv_cmd_pool {
716 struct list_head cmd_buffers;
717 };
718
719 #define ANV_CMD_BUFFER_BATCH_SIZE 8192
720
721 enum anv_cmd_buffer_exec_mode {
722 ANV_CMD_BUFFER_EXEC_MODE_PRIMARY,
723 ANV_CMD_BUFFER_EXEC_MODE_EMIT,
724 ANV_CMD_BUFFER_EXEC_MODE_CHAIN,
725 ANV_CMD_BUFFER_EXEC_MODE_COPY_AND_CHAIN,
726 };
727
728 struct anv_cmd_buffer {
729 struct anv_device * device;
730
731 struct list_head pool_link;
732
733 struct anv_batch batch;
734
735 /* Fields required for the actual chain of anv_batch_bo's.
736 *
737 * These fields are initialized by anv_cmd_buffer_init_batch_bo_chain().
738 */
739 struct list_head batch_bos;
740 struct list_head surface_bos;
741 uint32_t surface_next;
742 enum anv_cmd_buffer_exec_mode exec_mode;
743
744 /* A vector of anv_batch_bo pointers for every batch or surface buffer
745 * referenced by this command buffer
746 *
747 * initialized by anv_cmd_buffer_init_batch_bo_chain()
748 */
749 struct anv_vector seen_bbos;
750
751 /* Information needed for execbuf
752 *
753 * These fields are generated by anv_cmd_buffer_prepare_execbuf().
754 */
755 struct {
756 struct drm_i915_gem_execbuffer2 execbuf;
757
758 struct drm_i915_gem_exec_object2 * objects;
759 uint32_t bo_count;
760 struct anv_bo ** bos;
761
762 /* Allocated length of the 'objects' and 'bos' arrays */
763 uint32_t array_length;
764
765 bool need_reloc;
766 } execbuf2;
767
768 /* Serial for tracking buffer completion */
769 uint32_t serial;
770
771 /* Stream objects for storing temporary data */
772 struct anv_state_stream surface_state_stream;
773 struct anv_state_stream dynamic_state_stream;
774
775 VkCmdBufferOptimizeFlags opt_flags;
776 VkCmdBufferLevel level;
777
778 struct anv_cmd_state state;
779 };
780
781 VkResult anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer);
782 void anv_cmd_buffer_fini_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer);
783 void anv_cmd_buffer_reset_batch_bo_chain(struct anv_cmd_buffer *cmd_buffer);
784 void anv_cmd_buffer_end_batch_buffer(struct anv_cmd_buffer *cmd_buffer);
785 void anv_cmd_buffer_add_secondary(struct anv_cmd_buffer *primary,
786 struct anv_cmd_buffer *secondary);
787 void anv_cmd_buffer_prepare_execbuf(struct anv_cmd_buffer *cmd_buffer);
788
789 VkResult anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer,
790 unsigned stage, struct anv_state *bt_state);
791 VkResult anv_cmd_buffer_emit_samplers(struct anv_cmd_buffer *cmd_buffer,
792 unsigned stage, struct anv_state *state);
793 void anv_flush_descriptor_sets(struct anv_cmd_buffer *cmd_buffer);
794
795 struct anv_state anv_cmd_buffer_emit_dynamic(struct anv_cmd_buffer *cmd_buffer,
796 uint32_t *a, uint32_t dwords,
797 uint32_t alignment);
798 struct anv_state anv_cmd_buffer_merge_dynamic(struct anv_cmd_buffer *cmd_buffer,
799 uint32_t *a, uint32_t *b,
800 uint32_t dwords, uint32_t alignment);
801 void anv_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
802 struct anv_subpass *subpass);
803
804 struct anv_bo *
805 anv_cmd_buffer_current_surface_bo(struct anv_cmd_buffer *cmd_buffer);
806 struct anv_reloc_list *
807 anv_cmd_buffer_current_surface_relocs(struct anv_cmd_buffer *cmd_buffer);
808 struct anv_state
809 anv_cmd_buffer_alloc_surface_state(struct anv_cmd_buffer *cmd_buffer,
810 uint32_t size, uint32_t alignment);
811 struct anv_state
812 anv_cmd_buffer_alloc_dynamic_state(struct anv_cmd_buffer *cmd_buffer,
813 uint32_t size, uint32_t alignment);
814
815 VkResult anv_cmd_buffer_new_surface_state_bo(struct anv_cmd_buffer *cmd_buffer);
816
817 void gen7_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer);
818 void gen8_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer);
819
820 void anv_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer *cmd_buffer);
821
822 void gen7_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
823 struct anv_subpass *subpass);
824
825 void gen8_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
826 struct anv_subpass *subpass);
827
828 void anv_cmd_buffer_begin_subpass(struct anv_cmd_buffer *cmd_buffer,
829 struct anv_subpass *subpass);
830
831 void anv_cmd_buffer_clear_attachments(struct anv_cmd_buffer *cmd_buffer,
832 struct anv_render_pass *pass,
833 const VkClearValue *clear_values);
834
835 void anv_cmd_buffer_dump(struct anv_cmd_buffer *cmd_buffer);
836
837 struct anv_fence {
838 struct anv_bo bo;
839 struct drm_i915_gem_execbuffer2 execbuf;
840 struct drm_i915_gem_exec_object2 exec2_objects[1];
841 bool ready;
842 };
843
844 struct anv_shader_module {
845 uint32_t size;
846 char data[0];
847 };
848
849 struct anv_shader {
850 struct anv_shader_module * module;
851 char entrypoint[0];
852 };
853
854 struct anv_pipeline {
855 struct anv_device * device;
856 struct anv_batch batch;
857 uint32_t batch_data[256];
858 struct anv_reloc_list batch_relocs;
859 struct anv_shader * shaders[VK_SHADER_STAGE_NUM];
860 struct anv_pipeline_layout * layout;
861 bool use_repclear;
862
863 struct brw_vs_prog_data vs_prog_data;
864 struct brw_wm_prog_data wm_prog_data;
865 struct brw_gs_prog_data gs_prog_data;
866 struct brw_cs_prog_data cs_prog_data;
867 bool writes_point_size;
868 struct brw_stage_prog_data * prog_data[VK_SHADER_STAGE_NUM];
869 uint32_t scratch_start[VK_SHADER_STAGE_NUM];
870 uint32_t total_scratch;
871 struct {
872 uint32_t vs_start;
873 uint32_t vs_size;
874 uint32_t nr_vs_entries;
875 uint32_t gs_start;
876 uint32_t gs_size;
877 uint32_t nr_gs_entries;
878 } urb;
879
880 uint32_t active_stages;
881 struct anv_state_stream program_stream;
882 struct anv_state blend_state;
883 uint32_t vs_simd8;
884 uint32_t vs_vec4;
885 uint32_t ps_simd8;
886 uint32_t ps_simd16;
887 uint32_t ps_ksp0;
888 uint32_t ps_ksp2;
889 uint32_t ps_grf_start0;
890 uint32_t ps_grf_start2;
891 uint32_t gs_vec4;
892 uint32_t gs_vertex_count;
893 uint32_t cs_simd;
894
895 uint32_t vb_used;
896 uint32_t binding_stride[MAX_VBS];
897 bool instancing_enable[MAX_VBS];
898 bool primitive_restart;
899 uint32_t topology;
900
901 uint32_t cs_thread_width_max;
902 uint32_t cs_right_mask;
903
904 struct {
905 uint32_t sf[GEN7_3DSTATE_SF_length];
906 uint32_t depth_stencil_state[GEN7_DEPTH_STENCIL_STATE_length];
907 } gen7;
908
909 struct {
910 uint32_t sf[GEN8_3DSTATE_SF_length];
911 uint32_t vf[GEN8_3DSTATE_VF_length];
912 uint32_t raster[GEN8_3DSTATE_RASTER_length];
913 uint32_t wm_depth_stencil[GEN8_3DSTATE_WM_DEPTH_STENCIL_length];
914 } gen8;
915 };
916
917 struct anv_graphics_pipeline_create_info {
918 bool use_repclear;
919 bool disable_viewport;
920 bool disable_scissor;
921 bool disable_vs;
922 bool use_rectlist;
923 };
924
925 VkResult
926 anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device,
927 const VkGraphicsPipelineCreateInfo *pCreateInfo,
928 const struct anv_graphics_pipeline_create_info *extra);
929
930 VkResult
931 anv_graphics_pipeline_create(VkDevice device,
932 const VkGraphicsPipelineCreateInfo *pCreateInfo,
933 const struct anv_graphics_pipeline_create_info *extra,
934 VkPipeline *pPipeline);
935
936 VkResult
937 gen7_graphics_pipeline_create(VkDevice _device,
938 const VkGraphicsPipelineCreateInfo *pCreateInfo,
939 const struct anv_graphics_pipeline_create_info *extra,
940 VkPipeline *pPipeline);
941
942 VkResult
943 gen8_graphics_pipeline_create(VkDevice _device,
944 const VkGraphicsPipelineCreateInfo *pCreateInfo,
945 const struct anv_graphics_pipeline_create_info *extra,
946 VkPipeline *pPipeline);
947 VkResult
948 gen7_compute_pipeline_create(VkDevice _device,
949 const VkComputePipelineCreateInfo *pCreateInfo,
950 VkPipeline *pPipeline);
951
952 VkResult
953 gen8_compute_pipeline_create(VkDevice _device,
954 const VkComputePipelineCreateInfo *pCreateInfo,
955 VkPipeline *pPipeline);
956
957 struct anv_compiler *anv_compiler_create(struct anv_device *device);
958 void anv_compiler_destroy(struct anv_compiler *compiler);
959 int anv_compiler_run(struct anv_compiler *compiler, struct anv_pipeline *pipeline);
960 void anv_compiler_free(struct anv_pipeline *pipeline);
961
962 struct anv_format {
963 const VkFormat vk_format;
964 const char *name;
965 uint16_t surface_format; /**< RENDER_SURFACE_STATE.SurfaceFormat */
966 uint8_t cpp; /**< Bytes-per-pixel of anv_format::surface_format. */
967 uint8_t num_channels;
968 uint16_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */
969 bool has_stencil;
970 };
971
972 /**
973 * Stencil formats are often a special case. To reduce the number of lookups
974 * into the VkFormat-to-anv_format translation table when working with
975 * stencil, here is the handle to the table's entry for VK_FORMAT_S8_UINT.
976 */
977 extern const struct anv_format *const anv_format_s8_uint;
978
979 const struct anv_format *
980 anv_format_for_vk_format(VkFormat format);
981
982 static inline bool
983 anv_format_is_color(const struct anv_format *format)
984 {
985 return !format->depth_format && !format->has_stencil;
986 }
987
988 static inline bool
989 anv_format_is_depth_or_stencil(const struct anv_format *format)
990 {
991 return format->depth_format || format->has_stencil;
992 }
993
994 struct anv_image_view_info {
995 uint8_t surface_type; /**< RENDER_SURFACE_STATE.SurfaceType */
996 bool is_array:1; /**< RENDER_SURFACE_STATE.SurfaceArray */
997 bool is_cube:1; /**< RENDER_SURFACE_STATE.CubeFaceEnable* */
998 };
999
1000 const struct anv_image_view_info *
1001 anv_image_view_info_for_vk_image_view_type(VkImageViewType type);
1002
1003 /**
1004 * A proxy for the color surfaces, depth surfaces, and stencil surfaces.
1005 */
1006 struct anv_surface {
1007 /**
1008 * Offset from VkImage's base address, as bound by vkBindImageMemory().
1009 */
1010 uint32_t offset;
1011
1012 uint32_t stride; /**< RENDER_SURFACE_STATE.SurfacePitch */
1013 uint16_t qpitch; /**< RENDER_SURFACE_STATE.QPitch */
1014
1015 /**
1016 * \name Alignment of miptree images, in units of pixels.
1017 *
1018 * These fields contain the real alignment values, not the values to be
1019 * given to the GPU. For example, if h_align is 4, then program the GPU
1020 * with HALIGN_4.
1021 * \{
1022 */
1023 uint8_t h_align; /**< RENDER_SURFACE_STATE.SurfaceHorizontalAlignment */
1024 uint8_t v_align; /**< RENDER_SURFACE_STATE.SurfaceVerticalAlignment */
1025 /** \} */
1026
1027 uint8_t tile_mode; /**< RENDER_SURFACE_STATE.TileMode */
1028 };
1029
1030 struct anv_image {
1031 VkImageType type;
1032 const struct anv_format *format;
1033 VkExtent3D extent;
1034 uint32_t levels;
1035 uint32_t array_size;
1036
1037 VkDeviceSize size;
1038 uint32_t alignment;
1039
1040 /* Set when bound */
1041 struct anv_bo *bo;
1042 VkDeviceSize offset;
1043
1044 struct anv_swap_chain *swap_chain;
1045
1046 /** RENDER_SURFACE_STATE.SurfaceType */
1047 uint8_t surf_type;
1048
1049 /** Primary surface is either color or depth. */
1050 struct anv_surface primary_surface;
1051
1052 /** Stencil surface is optional. */
1053 struct anv_surface stencil_surface;
1054 };
1055
1056 struct anv_surface_view {
1057 struct anv_state surface_state; /**< RENDER_SURFACE_STATE */
1058 struct anv_bo *bo;
1059 uint32_t offset; /**< VkBufferCreateInfo::offset */
1060 uint32_t range; /**< VkBufferCreateInfo::range */
1061 const struct anv_format *format; /**< VkBufferCreateInfo::format */
1062 };
1063
1064 struct anv_buffer_view {
1065 struct anv_surface_view view;
1066 };
1067
1068 struct anv_image_view {
1069 struct anv_surface_view view;
1070 VkExtent3D extent;
1071 };
1072
1073 enum anv_attachment_view_type {
1074 ANV_ATTACHMENT_VIEW_TYPE_COLOR,
1075 ANV_ATTACHMENT_VIEW_TYPE_DEPTH_STENCIL,
1076 };
1077
1078 struct anv_attachment_view {
1079 enum anv_attachment_view_type attachment_type;
1080 VkExtent3D extent;
1081 };
1082
1083 struct anv_color_attachment_view {
1084 struct anv_attachment_view base;
1085 struct anv_surface_view view;
1086 };
1087
1088 struct anv_depth_stencil_view {
1089 struct anv_attachment_view base;
1090
1091 struct anv_bo *bo;
1092
1093 uint32_t depth_offset; /**< Offset into bo. */
1094 uint32_t depth_stride; /**< 3DSTATE_DEPTH_BUFFER.SurfacePitch */
1095 uint32_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */
1096 uint16_t depth_qpitch; /**< 3DSTATE_DEPTH_BUFFER.SurfaceQPitch */
1097
1098 uint32_t stencil_offset; /**< Offset into bo. */
1099 uint32_t stencil_stride; /**< 3DSTATE_STENCIL_BUFFER.SurfacePitch */
1100 uint16_t stencil_qpitch; /**< 3DSTATE_STENCIL_BUFFER.SurfaceQPitch */
1101 };
1102
1103 struct anv_image_create_info {
1104 const VkImageCreateInfo *vk_info;
1105 bool force_tile_mode;
1106 uint8_t tile_mode;
1107 uint32_t stride;
1108 };
1109
1110 VkResult anv_image_create(VkDevice _device,
1111 const struct anv_image_create_info *info,
1112 VkImage *pImage);
1113
1114 void anv_image_view_init(struct anv_image_view *view,
1115 struct anv_device *device,
1116 const VkImageViewCreateInfo* pCreateInfo,
1117 struct anv_cmd_buffer *cmd_buffer);
1118
1119 void
1120 gen7_image_view_init(struct anv_image_view *iview,
1121 struct anv_device *device,
1122 const VkImageViewCreateInfo* pCreateInfo,
1123 struct anv_cmd_buffer *cmd_buffer);
1124
1125 void
1126 gen8_image_view_init(struct anv_image_view *iview,
1127 struct anv_device *device,
1128 const VkImageViewCreateInfo* pCreateInfo,
1129 struct anv_cmd_buffer *cmd_buffer);
1130
1131 void anv_color_attachment_view_init(struct anv_color_attachment_view *view,
1132 struct anv_device *device,
1133 const VkAttachmentViewCreateInfo* pCreateInfo,
1134 struct anv_cmd_buffer *cmd_buffer);
1135
1136 void gen7_color_attachment_view_init(struct anv_color_attachment_view *aview,
1137 struct anv_device *device,
1138 const VkAttachmentViewCreateInfo* pCreateInfo,
1139 struct anv_cmd_buffer *cmd_buffer);
1140
1141 void gen8_color_attachment_view_init(struct anv_color_attachment_view *aview,
1142 struct anv_device *device,
1143 const VkAttachmentViewCreateInfo* pCreateInfo,
1144 struct anv_cmd_buffer *cmd_buffer);
1145
1146 VkResult anv_buffer_view_create(struct anv_device *device,
1147 const VkBufferViewCreateInfo *pCreateInfo,
1148 struct anv_buffer_view **view_out);
1149
1150 void anv_fill_buffer_surface_state(struct anv_device *device, void *state,
1151 const struct anv_format *format,
1152 uint32_t offset, uint32_t range);
1153
1154 void gen7_fill_buffer_surface_state(void *state, const struct anv_format *format,
1155 uint32_t offset, uint32_t range);
1156 void gen8_fill_buffer_surface_state(void *state, const struct anv_format *format,
1157 uint32_t offset, uint32_t range);
1158
1159 void anv_surface_view_fini(struct anv_device *device,
1160 struct anv_surface_view *view);
1161
1162 struct anv_sampler {
1163 uint32_t state[4];
1164 };
1165
1166 struct anv_framebuffer {
1167 uint32_t width;
1168 uint32_t height;
1169 uint32_t layers;
1170
1171 /* Viewport for clears */
1172 VkDynamicViewportState vp_state;
1173
1174 uint32_t attachment_count;
1175 const struct anv_attachment_view * attachments[0];
1176 };
1177
1178 struct anv_subpass {
1179 uint32_t input_count;
1180 uint32_t * input_attachments;
1181 uint32_t color_count;
1182 uint32_t * color_attachments;
1183 uint32_t * resolve_attachments;
1184 uint32_t depth_stencil_attachment;
1185 };
1186
1187 struct anv_render_pass_attachment {
1188 const struct anv_format *format;
1189 uint32_t samples;
1190 VkAttachmentLoadOp load_op;
1191 VkAttachmentLoadOp stencil_load_op;
1192 };
1193
1194 struct anv_render_pass {
1195 uint32_t attachment_count;
1196 uint32_t subpass_count;
1197
1198 uint32_t num_color_clear_attachments;
1199 bool has_depth_clear_attachment;
1200 bool has_stencil_clear_attachment;
1201
1202 struct anv_render_pass_attachment * attachments;
1203 struct anv_subpass subpasses[0];
1204 };
1205
1206 struct anv_query_pool_slot {
1207 uint64_t begin;
1208 uint64_t end;
1209 uint64_t available;
1210 };
1211
1212 struct anv_query_pool {
1213 VkQueryType type;
1214 uint32_t slots;
1215 struct anv_bo bo;
1216 };
1217
1218 void anv_device_init_meta(struct anv_device *device);
1219 void anv_device_finish_meta(struct anv_device *device);
1220
1221 void *anv_lookup_entrypoint(const char *name);
1222
1223 #define ANV_DEFINE_HANDLE_CASTS(__anv_type, __VkType) \
1224 \
1225 static inline struct __anv_type * \
1226 __anv_type ## _from_handle(__VkType _handle) \
1227 { \
1228 return (struct __anv_type *) _handle; \
1229 } \
1230 \
1231 static inline __VkType \
1232 __anv_type ## _to_handle(struct __anv_type *_obj) \
1233 { \
1234 return (__VkType) _obj; \
1235 }
1236
1237 #define ANV_DEFINE_NONDISP_HANDLE_CASTS(__anv_type, __VkType) \
1238 \
1239 static inline struct __anv_type * \
1240 __anv_type ## _from_handle(__VkType _handle) \
1241 { \
1242 return (struct __anv_type *) _handle.handle; \
1243 } \
1244 \
1245 static inline __VkType \
1246 __anv_type ## _to_handle(struct __anv_type *_obj) \
1247 { \
1248 return (__VkType) { .handle = (uint64_t) _obj }; \
1249 }
1250
1251 #define ANV_FROM_HANDLE(__anv_type, __name, __handle) \
1252 struct __anv_type *__name = __anv_type ## _from_handle(__handle)
1253
1254 ANV_DEFINE_HANDLE_CASTS(anv_cmd_buffer, VkCmdBuffer)
1255 ANV_DEFINE_HANDLE_CASTS(anv_device, VkDevice)
1256 ANV_DEFINE_HANDLE_CASTS(anv_instance, VkInstance)
1257 ANV_DEFINE_HANDLE_CASTS(anv_physical_device, VkPhysicalDevice)
1258 ANV_DEFINE_HANDLE_CASTS(anv_queue, VkQueue)
1259 ANV_DEFINE_HANDLE_CASTS(anv_swap_chain, VkSwapChainWSI);
1260
1261 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_cmd_pool, VkCmdPool)
1262 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_attachment_view, VkAttachmentView)
1263 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer, VkBuffer)
1264 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer_view, VkBufferView);
1265 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set, VkDescriptorSet)
1266 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set_layout, VkDescriptorSetLayout)
1267 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_device_memory, VkDeviceMemory)
1268 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_dynamic_cb_state, VkDynamicColorBlendState)
1269 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_dynamic_ds_state, VkDynamicDepthStencilState)
1270 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_dynamic_rs_state, VkDynamicRasterState)
1271 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_dynamic_vp_state, VkDynamicViewportState)
1272 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_fence, VkFence)
1273 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_framebuffer, VkFramebuffer)
1274 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_image, VkImage)
1275 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_image_view, VkImageView);
1276 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline, VkPipeline)
1277 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline_layout, VkPipelineLayout)
1278 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_query_pool, VkQueryPool)
1279 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_render_pass, VkRenderPass)
1280 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_sampler, VkSampler)
1281 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader, VkShader)
1282 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader_module, VkShaderModule)
1283
1284 #define ANV_DEFINE_STRUCT_CASTS(__anv_type, __VkType) \
1285 \
1286 static inline const __VkType * \
1287 __anv_type ## _to_ ## __VkType(const struct __anv_type *__anv_obj) \
1288 { \
1289 return (const __VkType *) __anv_obj; \
1290 }
1291
1292 #define ANV_COMMON_TO_STRUCT(__VkType, __vk_name, __common_name) \
1293 const __VkType *__vk_name = anv_common_to_ ## __VkType(__common_name)
1294
1295 ANV_DEFINE_STRUCT_CASTS(anv_common, VkMemoryBarrier)
1296 ANV_DEFINE_STRUCT_CASTS(anv_common, VkBufferMemoryBarrier)
1297 ANV_DEFINE_STRUCT_CASTS(anv_common, VkImageMemoryBarrier)
1298
1299 #ifdef __cplusplus
1300 }
1301 #endif