2 * Copyright © 2015 Intel Corporation
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
40 #define __gen_validate_value(x) VALGRIND_CHECK_MEM_IS_DEFINED(&(x), sizeof(x))
46 #include "common/gen_clflush.h"
47 #include "common/gen_gem.h"
48 #include "dev/gen_device_info.h"
49 #include "blorp/blorp.h"
50 #include "compiler/brw_compiler.h"
51 #include "util/macros.h"
52 #include "util/hash_table.h"
53 #include "util/list.h"
55 #include "util/u_atomic.h"
56 #include "util/u_vector.h"
57 #include "util/u_math.h"
60 #include "vk_debug_report.h"
62 /* Pre-declarations needed for WSI entrypoints */
65 typedef struct xcb_connection_t xcb_connection_t
;
66 typedef uint32_t xcb_visualid_t
;
67 typedef uint32_t xcb_window_t
;
70 struct anv_buffer_view
;
71 struct anv_image_view
;
76 #include <vulkan/vulkan.h>
77 #include <vulkan/vulkan_intel.h>
78 #include <vulkan/vk_icd.h>
80 #include "anv_android.h"
81 #include "anv_entrypoints.h"
82 #include "anv_extensions.h"
85 #include "common/gen_debug.h"
86 #include "common/intel_log.h"
87 #include "wsi_common.h"
89 /* anv Virtual Memory Layout
90 * =========================
92 * When the anv driver is determining the virtual graphics addresses of memory
93 * objects itself using the softpin mechanism, the following memory ranges
96 * Three special considerations to notice:
98 * (1) the dynamic state pool is located within the same 4 GiB as the low
99 * heap. This is to work around a VF cache issue described in a comment in
100 * anv_physical_device_init_heaps.
102 * (2) the binding table pool is located at lower addresses than the surface
103 * state pool, within a 4 GiB range. This allows surface state base addresses
104 * to cover both binding tables (16 bit offsets) and surface states (32 bit
107 * (3) the last 4 GiB of the address space is withheld from the high
108 * heap. Various hardware units will read past the end of an object for
109 * various reasons. This healthy margin prevents reads from wrapping around
112 #define LOW_HEAP_MIN_ADDRESS 0x000000001000ULL /* 4 KiB */
113 #define LOW_HEAP_MAX_ADDRESS 0x0000bfffffffULL
114 #define DYNAMIC_STATE_POOL_MIN_ADDRESS 0x0000c0000000ULL /* 3 GiB */
115 #define DYNAMIC_STATE_POOL_MAX_ADDRESS 0x0000ffffffffULL
116 #define BINDING_TABLE_POOL_MIN_ADDRESS 0x000100000000ULL /* 4 GiB */
117 #define BINDING_TABLE_POOL_MAX_ADDRESS 0x00013fffffffULL
118 #define SURFACE_STATE_POOL_MIN_ADDRESS 0x000140000000ULL /* 5 GiB */
119 #define SURFACE_STATE_POOL_MAX_ADDRESS 0x00017fffffffULL
120 #define INSTRUCTION_STATE_POOL_MIN_ADDRESS 0x000180000000ULL /* 6 GiB */
121 #define INSTRUCTION_STATE_POOL_MAX_ADDRESS 0x0001bfffffffULL
122 #define HIGH_HEAP_MIN_ADDRESS 0x0001c0000000ULL /* 7 GiB */
123 #define HIGH_HEAP_MAX_ADDRESS 0xfffeffffffffULL
125 #define LOW_HEAP_SIZE \
126 (LOW_HEAP_MAX_ADDRESS - LOW_HEAP_MIN_ADDRESS + 1)
127 #define HIGH_HEAP_SIZE \
128 (HIGH_HEAP_MAX_ADDRESS - HIGH_HEAP_MIN_ADDRESS + 1)
129 #define DYNAMIC_STATE_POOL_SIZE \
130 (DYNAMIC_STATE_POOL_MAX_ADDRESS - DYNAMIC_STATE_POOL_MIN_ADDRESS + 1)
131 #define BINDING_TABLE_POOL_SIZE \
132 (BINDING_TABLE_POOL_MAX_ADDRESS - BINDING_TABLE_POOL_MIN_ADDRESS + 1)
133 #define SURFACE_STATE_POOL_SIZE \
134 (SURFACE_STATE_POOL_MAX_ADDRESS - SURFACE_STATE_POOL_MIN_ADDRESS + 1)
135 #define INSTRUCTION_STATE_POOL_SIZE \
136 (INSTRUCTION_STATE_POOL_MAX_ADDRESS - INSTRUCTION_STATE_POOL_MIN_ADDRESS + 1)
138 /* Allowing different clear colors requires us to perform a depth resolve at
139 * the end of certain render passes. This is because while slow clears store
140 * the clear color in the HiZ buffer, fast clears (without a resolve) don't.
141 * See the PRMs for examples describing when additional resolves would be
142 * necessary. To enable fast clears without requiring extra resolves, we set
143 * the clear value to a globally-defined one. We could allow different values
144 * if the user doesn't expect coherent data during or after a render passes
145 * (VK_ATTACHMENT_STORE_OP_DONT_CARE), but such users (aside from the CTS)
146 * don't seem to exist yet. In almost all Vulkan applications tested thus far,
147 * 1.0f seems to be the only value used. The only application that doesn't set
148 * this value does so through the usage of an seemingly uninitialized clear
151 #define ANV_HZ_FC_VAL 1.0f
156 #define MAX_VIEWPORTS 16
157 #define MAX_SCISSORS 16
158 #define MAX_PUSH_CONSTANTS_SIZE 128
159 #define MAX_DYNAMIC_BUFFERS 16
161 #define MAX_PUSH_DESCRIPTORS 32 /* Minimum requirement */
163 /* The kernel relocation API has a limitation of a 32-bit delta value
164 * applied to the address before it is written which, in spite of it being
165 * unsigned, is treated as signed . Because of the way that this maps to
166 * the Vulkan API, we cannot handle an offset into a buffer that does not
167 * fit into a signed 32 bits. The only mechanism we have for dealing with
168 * this at the moment is to limit all VkDeviceMemory objects to a maximum
169 * of 2GB each. The Vulkan spec allows us to do this:
171 * "Some platforms may have a limit on the maximum size of a single
172 * allocation. For example, certain systems may fail to create
173 * allocations with a size greater than or equal to 4GB. Such a limit is
174 * implementation-dependent, and if such a failure occurs then the error
175 * VK_ERROR_OUT_OF_DEVICE_MEMORY should be returned."
177 * We don't use vk_error here because it's not an error so much as an
178 * indication to the application that the allocation is too large.
180 #define MAX_MEMORY_ALLOCATION_SIZE (1ull << 31)
182 #define ANV_SVGS_VB_INDEX MAX_VBS
183 #define ANV_DRAWID_VB_INDEX (MAX_VBS + 1)
185 #define anv_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
187 static inline uint32_t
188 align_down_npot_u32(uint32_t v
, uint32_t a
)
193 static inline uint32_t
194 align_u32(uint32_t v
, uint32_t a
)
196 assert(a
!= 0 && a
== (a
& -a
));
197 return (v
+ a
- 1) & ~(a
- 1);
200 static inline uint64_t
201 align_u64(uint64_t v
, uint64_t a
)
203 assert(a
!= 0 && a
== (a
& -a
));
204 return (v
+ a
- 1) & ~(a
- 1);
207 static inline int32_t
208 align_i32(int32_t v
, int32_t a
)
210 assert(a
!= 0 && a
== (a
& -a
));
211 return (v
+ a
- 1) & ~(a
- 1);
214 /** Alignment must be a power of 2. */
216 anv_is_aligned(uintmax_t n
, uintmax_t a
)
218 assert(a
== (a
& -a
));
219 return (n
& (a
- 1)) == 0;
222 static inline uint32_t
223 anv_minify(uint32_t n
, uint32_t levels
)
225 if (unlikely(n
== 0))
228 return MAX2(n
>> levels
, 1);
232 anv_clamp_f(float f
, float min
, float max
)
245 anv_clear_mask(uint32_t *inout_mask
, uint32_t clear_mask
)
247 if (*inout_mask
& clear_mask
) {
248 *inout_mask
&= ~clear_mask
;
255 static inline union isl_color_value
256 vk_to_isl_color(VkClearColorValue color
)
258 return (union isl_color_value
) {
268 #define for_each_bit(b, dword) \
269 for (uint32_t __dword = (dword); \
270 (b) = __builtin_ffs(__dword) - 1, __dword; \
271 __dword &= ~(1 << (b)))
273 #define typed_memcpy(dest, src, count) ({ \
274 STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
275 memcpy((dest), (src), (count) * sizeof(*(src))); \
278 /* Mapping from anv object to VkDebugReportObjectTypeEXT. New types need
279 * to be added here in order to utilize mapping in debug/error/perf macros.
281 #define REPORT_OBJECT_TYPE(o) \
282 __builtin_choose_expr ( \
283 __builtin_types_compatible_p (__typeof (o), struct anv_instance*), \
284 VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, \
285 __builtin_choose_expr ( \
286 __builtin_types_compatible_p (__typeof (o), struct anv_physical_device*), \
287 VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, \
288 __builtin_choose_expr ( \
289 __builtin_types_compatible_p (__typeof (o), struct anv_device*), \
290 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, \
291 __builtin_choose_expr ( \
292 __builtin_types_compatible_p (__typeof (o), const struct anv_device*), \
293 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT, \
294 __builtin_choose_expr ( \
295 __builtin_types_compatible_p (__typeof (o), struct anv_queue*), \
296 VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, \
297 __builtin_choose_expr ( \
298 __builtin_types_compatible_p (__typeof (o), struct anv_semaphore*), \
299 VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, \
300 __builtin_choose_expr ( \
301 __builtin_types_compatible_p (__typeof (o), struct anv_cmd_buffer*), \
302 VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, \
303 __builtin_choose_expr ( \
304 __builtin_types_compatible_p (__typeof (o), struct anv_fence*), \
305 VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT, \
306 __builtin_choose_expr ( \
307 __builtin_types_compatible_p (__typeof (o), struct anv_device_memory*), \
308 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, \
309 __builtin_choose_expr ( \
310 __builtin_types_compatible_p (__typeof (o), struct anv_buffer*), \
311 VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, \
312 __builtin_choose_expr ( \
313 __builtin_types_compatible_p (__typeof (o), struct anv_image*), \
314 VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, \
315 __builtin_choose_expr ( \
316 __builtin_types_compatible_p (__typeof (o), const struct anv_image*), \
317 VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, \
318 __builtin_choose_expr ( \
319 __builtin_types_compatible_p (__typeof (o), struct anv_event*), \
320 VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT, \
321 __builtin_choose_expr ( \
322 __builtin_types_compatible_p (__typeof (o), struct anv_query_pool*), \
323 VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT, \
324 __builtin_choose_expr ( \
325 __builtin_types_compatible_p (__typeof (o), struct anv_buffer_view*), \
326 VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT, \
327 __builtin_choose_expr ( \
328 __builtin_types_compatible_p (__typeof (o), struct anv_image_view*), \
329 VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT, \
330 __builtin_choose_expr ( \
331 __builtin_types_compatible_p (__typeof (o), struct anv_shader_module*), \
332 VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT, \
333 __builtin_choose_expr ( \
334 __builtin_types_compatible_p (__typeof (o), struct anv_pipeline_cache*), \
335 VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT, \
336 __builtin_choose_expr ( \
337 __builtin_types_compatible_p (__typeof (o), struct anv_pipeline_layout*), \
338 VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT, \
339 __builtin_choose_expr ( \
340 __builtin_types_compatible_p (__typeof (o), struct anv_render_pass*), \
341 VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, \
342 __builtin_choose_expr ( \
343 __builtin_types_compatible_p (__typeof (o), struct anv_pipeline*), \
344 VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, \
345 __builtin_choose_expr ( \
346 __builtin_types_compatible_p (__typeof (o), struct anv_descriptor_set_layout*), \
347 VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT, \
348 __builtin_choose_expr ( \
349 __builtin_types_compatible_p (__typeof (o), struct anv_sampler*), \
350 VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT, \
351 __builtin_choose_expr ( \
352 __builtin_types_compatible_p (__typeof (o), struct anv_descriptor_pool*), \
353 VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, \
354 __builtin_choose_expr ( \
355 __builtin_types_compatible_p (__typeof (o), struct anv_descriptor_set*), \
356 VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, \
357 __builtin_choose_expr ( \
358 __builtin_types_compatible_p (__typeof (o), struct anv_framebuffer*), \
359 VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT, \
360 __builtin_choose_expr ( \
361 __builtin_types_compatible_p (__typeof (o), struct anv_cmd_pool*), \
362 VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT, \
363 __builtin_choose_expr ( \
364 __builtin_types_compatible_p (__typeof (o), struct anv_surface*), \
365 VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT, \
366 __builtin_choose_expr ( \
367 __builtin_types_compatible_p (__typeof (o), struct wsi_swapchain*), \
368 VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT, \
369 __builtin_choose_expr ( \
370 __builtin_types_compatible_p (__typeof (o), struct vk_debug_callback*), \
371 VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT, \
372 __builtin_choose_expr ( \
373 __builtin_types_compatible_p (__typeof (o), void*), \
374 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT, \
375 /* The void expression results in a compile-time error \
376 when assigning the result to something. */ \
377 (void)0)))))))))))))))))))))))))))))))
379 /* Whenever we generate an error, pass it through this function. Useful for
380 * debugging, where we can break on it. Only call at error site, not when
381 * propagating errors. Might be useful to plug in a stack trace here.
384 VkResult
__vk_errorv(struct anv_instance
*instance
, const void *object
,
385 VkDebugReportObjectTypeEXT type
, VkResult error
,
386 const char *file
, int line
, const char *format
,
389 VkResult
__vk_errorf(struct anv_instance
*instance
, const void *object
,
390 VkDebugReportObjectTypeEXT type
, VkResult error
,
391 const char *file
, int line
, const char *format
, ...);
394 #define vk_error(error) __vk_errorf(NULL, NULL,\
395 VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,\
396 error, __FILE__, __LINE__, NULL)
397 #define vk_errorv(instance, obj, error, format, args)\
398 __vk_errorv(instance, obj, REPORT_OBJECT_TYPE(obj), error,\
399 __FILE__, __LINE__, format, args)
400 #define vk_errorf(instance, obj, error, format, ...)\
401 __vk_errorf(instance, obj, REPORT_OBJECT_TYPE(obj), error,\
402 __FILE__, __LINE__, format, ## __VA_ARGS__)
404 #define vk_error(error) error
405 #define vk_errorf(instance, obj, error, format, ...) error
409 * Warn on ignored extension structs.
411 * The Vulkan spec requires us to ignore unsupported or unknown structs in
412 * a pNext chain. In debug mode, emitting warnings for ignored structs may
413 * help us discover structs that we should not have ignored.
416 * From the Vulkan 1.0.38 spec:
418 * Any component of the implementation (the loader, any enabled layers,
419 * and drivers) must skip over, without processing (other than reading the
420 * sType and pNext members) any chained structures with sType values not
421 * defined by extensions supported by that component.
423 #define anv_debug_ignored_stype(sType) \
424 intel_logd("%s: ignored VkStructureType %u\n", __func__, (sType))
426 void __anv_perf_warn(struct anv_instance
*instance
, const void *object
,
427 VkDebugReportObjectTypeEXT type
, const char *file
,
428 int line
, const char *format
, ...)
429 anv_printflike(6, 7);
430 void anv_loge(const char *format
, ...) anv_printflike(1, 2);
431 void anv_loge_v(const char *format
, va_list va
);
434 * Print a FINISHME message, including its source location.
436 #define anv_finishme(format, ...) \
438 static bool reported = false; \
440 intel_logw("%s:%d: FINISHME: " format, __FILE__, __LINE__, \
447 * Print a perf warning message. Set INTEL_DEBUG=perf to see these.
449 #define anv_perf_warn(instance, obj, format, ...) \
451 static bool reported = false; \
452 if (!reported && unlikely(INTEL_DEBUG & DEBUG_PERF)) { \
453 __anv_perf_warn(instance, obj, REPORT_OBJECT_TYPE(obj), __FILE__, __LINE__,\
454 format, ##__VA_ARGS__); \
459 /* A non-fatal assert. Useful for debugging. */
461 #define anv_assert(x) ({ \
462 if (unlikely(!(x))) \
463 intel_loge("%s:%d ASSERT: %s", __FILE__, __LINE__, #x); \
466 #define anv_assert(x)
469 /* A multi-pointer allocator
471 * When copying data structures from the user (such as a render pass), it's
472 * common to need to allocate data for a bunch of different things. Instead
473 * of doing several allocations and having to handle all of the error checking
474 * that entails, it can be easier to do a single allocation. This struct
475 * helps facilitate that. The intended usage looks like this:
478 * anv_multialloc_add(&ma, &main_ptr, 1);
479 * anv_multialloc_add(&ma, &substruct1, substruct1Count);
480 * anv_multialloc_add(&ma, &substruct2, substruct2Count);
482 * if (!anv_multialloc_alloc(&ma, pAllocator, VK_ALLOCATION_SCOPE_FOO))
483 * return vk_error(VK_ERROR_OUT_OF_HOST_MEORY);
485 struct anv_multialloc
{
493 #define ANV_MULTIALLOC_INIT \
494 ((struct anv_multialloc) { 0, })
496 #define ANV_MULTIALLOC(_name) \
497 struct anv_multialloc _name = ANV_MULTIALLOC_INIT
499 __attribute__((always_inline
))
501 _anv_multialloc_add(struct anv_multialloc
*ma
,
502 void **ptr
, size_t size
, size_t align
)
504 size_t offset
= align_u64(ma
->size
, align
);
505 ma
->size
= offset
+ size
;
506 ma
->align
= MAX2(ma
->align
, align
);
508 /* Store the offset in the pointer. */
509 *ptr
= (void *)(uintptr_t)offset
;
511 assert(ma
->ptr_count
< ARRAY_SIZE(ma
->ptrs
));
512 ma
->ptrs
[ma
->ptr_count
++] = ptr
;
515 #define anv_multialloc_add_size(_ma, _ptr, _size) \
516 _anv_multialloc_add((_ma), (void **)(_ptr), (_size), __alignof__(**(_ptr)))
518 #define anv_multialloc_add(_ma, _ptr, _count) \
519 anv_multialloc_add_size(_ma, _ptr, (_count) * sizeof(**(_ptr)));
521 __attribute__((always_inline
))
523 anv_multialloc_alloc(struct anv_multialloc
*ma
,
524 const VkAllocationCallbacks
*alloc
,
525 VkSystemAllocationScope scope
)
527 void *ptr
= vk_alloc(alloc
, ma
->size
, ma
->align
, scope
);
531 /* Fill out each of the pointers with their final value.
533 * for (uint32_t i = 0; i < ma->ptr_count; i++)
534 * *ma->ptrs[i] = ptr + (uintptr_t)*ma->ptrs[i];
536 * Unfortunately, even though ma->ptr_count is basically guaranteed to be a
537 * constant, GCC is incapable of figuring this out and unrolling the loop
538 * so we have to give it a little help.
540 STATIC_ASSERT(ARRAY_SIZE(ma
->ptrs
) == 8);
541 #define _ANV_MULTIALLOC_UPDATE_POINTER(_i) \
542 if ((_i) < ma->ptr_count) \
543 *ma->ptrs[_i] = ptr + (uintptr_t)*ma->ptrs[_i]
544 _ANV_MULTIALLOC_UPDATE_POINTER(0);
545 _ANV_MULTIALLOC_UPDATE_POINTER(1);
546 _ANV_MULTIALLOC_UPDATE_POINTER(2);
547 _ANV_MULTIALLOC_UPDATE_POINTER(3);
548 _ANV_MULTIALLOC_UPDATE_POINTER(4);
549 _ANV_MULTIALLOC_UPDATE_POINTER(5);
550 _ANV_MULTIALLOC_UPDATE_POINTER(6);
551 _ANV_MULTIALLOC_UPDATE_POINTER(7);
552 #undef _ANV_MULTIALLOC_UPDATE_POINTER
557 __attribute__((always_inline
))
559 anv_multialloc_alloc2(struct anv_multialloc
*ma
,
560 const VkAllocationCallbacks
*parent_alloc
,
561 const VkAllocationCallbacks
*alloc
,
562 VkSystemAllocationScope scope
)
564 return anv_multialloc_alloc(ma
, alloc
? alloc
: parent_alloc
, scope
);
567 /* Extra ANV-defined BO flags which won't be passed to the kernel */
568 #define ANV_BO_EXTERNAL (1ull << 31)
569 #define ANV_BO_FLAG_MASK (1ull << 31)
574 /* Index into the current validation list. This is used by the
575 * validation list building alrogithm to track which buffers are already
576 * in the validation list so that we can ensure uniqueness.
580 /* Last known offset. This value is provided by the kernel when we
581 * execbuf and is used as the presumed offset for the next bunch of
589 /** Flags to pass to the kernel through drm_i915_exec_object2::flags */
594 anv_bo_init(struct anv_bo
*bo
, uint32_t gem_handle
, uint64_t size
)
596 bo
->gem_handle
= gem_handle
;
604 /* Represents a lock-free linked list of "free" things. This is used by
605 * both the block pool and the state pools. Unfortunately, in order to
606 * solve the ABA problem, we can't use a single uint32_t head.
608 union anv_free_list
{
612 /* A simple count that is incremented every time the head changes. */
618 #define ANV_FREE_LIST_EMPTY ((union anv_free_list) { { 1, 0 } })
620 struct anv_block_state
{
630 struct anv_block_pool
{
631 struct anv_device
*device
;
637 /* The address where the start of the pool is pinned. The various bos that
638 * are created as the pool grows will have addresses in the range
639 * [start_address, start_address + BLOCK_POOL_MEMFD_SIZE).
641 uint64_t start_address
;
643 /* The offset from the start of the bo to the "center" of the block
644 * pool. Pointers to allocated blocks are given by
645 * bo.map + center_bo_offset + offsets.
647 uint32_t center_bo_offset
;
649 /* Current memory map of the block pool. This pointer may or may not
650 * point to the actual beginning of the block pool memory. If
651 * anv_block_pool_alloc_back has ever been called, then this pointer
652 * will point to the "center" position of the buffer and all offsets
653 * (negative or positive) given out by the block pool alloc functions
654 * will be valid relative to this pointer.
656 * In particular, map == bo.map + center_offset
662 * Array of mmaps and gem handles owned by the block pool, reclaimed when
663 * the block pool is destroyed.
665 struct u_vector mmap_cleanups
;
667 struct anv_block_state state
;
669 struct anv_block_state back_state
;
672 /* Block pools are backed by a fixed-size 1GB memfd */
673 #define BLOCK_POOL_MEMFD_SIZE (1ul << 30)
675 /* The center of the block pool is also the middle of the memfd. This may
676 * change in the future if we decide differently for some reason.
678 #define BLOCK_POOL_MEMFD_CENTER (BLOCK_POOL_MEMFD_SIZE / 2)
680 static inline uint32_t
681 anv_block_pool_size(struct anv_block_pool
*pool
)
683 return pool
->state
.end
+ pool
->back_state
.end
;
692 #define ANV_STATE_NULL ((struct anv_state) { .alloc_size = 0 })
694 struct anv_fixed_size_state_pool
{
695 union anv_free_list free_list
;
696 struct anv_block_state block
;
699 #define ANV_MIN_STATE_SIZE_LOG2 6
700 #define ANV_MAX_STATE_SIZE_LOG2 20
702 #define ANV_STATE_BUCKETS (ANV_MAX_STATE_SIZE_LOG2 - ANV_MIN_STATE_SIZE_LOG2 + 1)
704 struct anv_state_pool
{
705 struct anv_block_pool block_pool
;
707 /* The size of blocks which will be allocated from the block pool */
710 /** Free list for "back" allocations */
711 union anv_free_list back_alloc_free_list
;
713 struct anv_fixed_size_state_pool buckets
[ANV_STATE_BUCKETS
];
716 struct anv_state_stream_block
;
718 struct anv_state_stream
{
719 struct anv_state_pool
*state_pool
;
721 /* The size of blocks to allocate from the state pool */
724 /* Current block we're allocating from */
725 struct anv_state block
;
727 /* Offset into the current block at which to allocate the next state */
730 /* List of all blocks allocated from this pool */
731 struct anv_state_stream_block
*block_list
;
734 /* The block_pool functions exported for testing only. The block pool should
735 * only be used via a state pool (see below).
737 VkResult
anv_block_pool_init(struct anv_block_pool
*pool
,
738 struct anv_device
*device
,
739 uint64_t start_address
,
740 uint32_t initial_size
,
742 void anv_block_pool_finish(struct anv_block_pool
*pool
);
743 int32_t anv_block_pool_alloc(struct anv_block_pool
*pool
,
744 uint32_t block_size
);
745 int32_t anv_block_pool_alloc_back(struct anv_block_pool
*pool
,
746 uint32_t block_size
);
748 VkResult
anv_state_pool_init(struct anv_state_pool
*pool
,
749 struct anv_device
*device
,
750 uint64_t start_address
,
753 void anv_state_pool_finish(struct anv_state_pool
*pool
);
754 struct anv_state
anv_state_pool_alloc(struct anv_state_pool
*pool
,
755 uint32_t state_size
, uint32_t alignment
);
756 struct anv_state
anv_state_pool_alloc_back(struct anv_state_pool
*pool
);
757 void anv_state_pool_free(struct anv_state_pool
*pool
, struct anv_state state
);
758 void anv_state_stream_init(struct anv_state_stream
*stream
,
759 struct anv_state_pool
*state_pool
,
760 uint32_t block_size
);
761 void anv_state_stream_finish(struct anv_state_stream
*stream
);
762 struct anv_state
anv_state_stream_alloc(struct anv_state_stream
*stream
,
763 uint32_t size
, uint32_t alignment
);
766 * Implements a pool of re-usable BOs. The interface is identical to that
767 * of block_pool except that each block is its own BO.
770 struct anv_device
*device
;
777 void anv_bo_pool_init(struct anv_bo_pool
*pool
, struct anv_device
*device
,
779 void anv_bo_pool_finish(struct anv_bo_pool
*pool
);
780 VkResult
anv_bo_pool_alloc(struct anv_bo_pool
*pool
, struct anv_bo
*bo
,
782 void anv_bo_pool_free(struct anv_bo_pool
*pool
, const struct anv_bo
*bo
);
784 struct anv_scratch_bo
{
789 struct anv_scratch_pool
{
790 /* Indexed by Per-Thread Scratch Space number (the hardware value) and stage */
791 struct anv_scratch_bo bos
[16][MESA_SHADER_STAGES
];
794 void anv_scratch_pool_init(struct anv_device
*device
,
795 struct anv_scratch_pool
*pool
);
796 void anv_scratch_pool_finish(struct anv_device
*device
,
797 struct anv_scratch_pool
*pool
);
798 struct anv_bo
*anv_scratch_pool_alloc(struct anv_device
*device
,
799 struct anv_scratch_pool
*pool
,
800 gl_shader_stage stage
,
801 unsigned per_thread_scratch
);
803 /** Implements a BO cache that ensures a 1-1 mapping of GEM BOs to anv_bos */
804 struct anv_bo_cache
{
805 struct hash_table
*bo_map
;
806 pthread_mutex_t mutex
;
809 VkResult
anv_bo_cache_init(struct anv_bo_cache
*cache
);
810 void anv_bo_cache_finish(struct anv_bo_cache
*cache
);
811 VkResult
anv_bo_cache_alloc(struct anv_device
*device
,
812 struct anv_bo_cache
*cache
,
813 uint64_t size
, uint64_t bo_flags
,
815 VkResult
anv_bo_cache_import(struct anv_device
*device
,
816 struct anv_bo_cache
*cache
,
817 int fd
, uint64_t bo_flags
,
819 VkResult
anv_bo_cache_export(struct anv_device
*device
,
820 struct anv_bo_cache
*cache
,
821 struct anv_bo
*bo_in
, int *fd_out
);
822 void anv_bo_cache_release(struct anv_device
*device
,
823 struct anv_bo_cache
*cache
,
826 struct anv_memory_type
{
827 /* Standard bits passed on to the client */
828 VkMemoryPropertyFlags propertyFlags
;
831 /* Driver-internal book-keeping */
832 VkBufferUsageFlags valid_buffer_usage
;
835 struct anv_memory_heap
{
836 /* Standard bits passed on to the client */
838 VkMemoryHeapFlags flags
;
840 /* Driver-internal book-keeping */
841 bool supports_48bit_addresses
;
844 struct anv_physical_device
{
845 VK_LOADER_DATA _loader_data
;
847 struct anv_instance
* instance
;
858 struct gen_device_info info
;
859 /** Amount of "GPU memory" we want to advertise
861 * Clearly, this value is bogus since Intel is a UMA architecture. On
862 * gen7 platforms, we are limited by GTT size unless we want to implement
863 * fine-grained tracking and GTT splitting. On Broadwell and above we are
864 * practically unlimited. However, we will never report more than 3/4 of
865 * the total system ram to try and avoid running out of RAM.
867 bool supports_48bit_addresses
;
868 struct brw_compiler
* compiler
;
869 struct isl_device isl_dev
;
870 int cmd_parser_version
;
872 bool has_exec_capture
;
875 bool has_syncobj_wait
;
876 bool has_context_priority
;
878 bool has_context_isolation
;
880 struct anv_device_extension_table supported_extensions
;
883 uint32_t subslice_total
;
887 struct anv_memory_type types
[VK_MAX_MEMORY_TYPES
];
889 struct anv_memory_heap heaps
[VK_MAX_MEMORY_HEAPS
];
892 uint8_t driver_build_sha1
[20];
893 uint8_t pipeline_cache_uuid
[VK_UUID_SIZE
];
894 uint8_t driver_uuid
[VK_UUID_SIZE
];
895 uint8_t device_uuid
[VK_UUID_SIZE
];
897 struct disk_cache
* disk_cache
;
899 struct wsi_device wsi_device
;
904 struct anv_app_info
{
905 const char* app_name
;
906 uint32_t app_version
;
907 const char* engine_name
;
908 uint32_t engine_version
;
909 uint32_t api_version
;
912 struct anv_instance
{
913 VK_LOADER_DATA _loader_data
;
915 VkAllocationCallbacks alloc
;
917 struct anv_app_info app_info
;
919 struct anv_instance_extension_table enabled_extensions
;
920 struct anv_instance_dispatch_table dispatch
;
921 struct anv_device_dispatch_table device_dispatch
;
923 int physicalDeviceCount
;
924 struct anv_physical_device physicalDevice
;
926 bool pipeline_cache_enabled
;
928 struct vk_debug_report_instance debug_report_callbacks
;
931 VkResult
anv_init_wsi(struct anv_physical_device
*physical_device
);
932 void anv_finish_wsi(struct anv_physical_device
*physical_device
);
934 uint32_t anv_physical_device_api_version(struct anv_physical_device
*dev
);
935 bool anv_physical_device_extension_supported(struct anv_physical_device
*dev
,
939 VK_LOADER_DATA _loader_data
;
941 struct anv_device
* device
;
943 VkDeviceQueueCreateFlags flags
;
946 struct anv_pipeline_cache
{
947 struct anv_device
* device
;
948 pthread_mutex_t mutex
;
950 struct hash_table
* cache
;
953 struct anv_pipeline_bind_map
;
955 void anv_pipeline_cache_init(struct anv_pipeline_cache
*cache
,
956 struct anv_device
*device
,
958 void anv_pipeline_cache_finish(struct anv_pipeline_cache
*cache
);
960 struct anv_shader_bin
*
961 anv_pipeline_cache_search(struct anv_pipeline_cache
*cache
,
962 const void *key
, uint32_t key_size
);
963 struct anv_shader_bin
*
964 anv_pipeline_cache_upload_kernel(struct anv_pipeline_cache
*cache
,
965 const void *key_data
, uint32_t key_size
,
966 const void *kernel_data
, uint32_t kernel_size
,
967 const void *constant_data
,
968 uint32_t constant_data_size
,
969 const struct brw_stage_prog_data
*prog_data
,
970 uint32_t prog_data_size
,
971 const struct anv_pipeline_bind_map
*bind_map
);
973 struct anv_shader_bin
*
974 anv_device_search_for_kernel(struct anv_device
*device
,
975 struct anv_pipeline_cache
*cache
,
976 const void *key_data
, uint32_t key_size
);
978 struct anv_shader_bin
*
979 anv_device_upload_kernel(struct anv_device
*device
,
980 struct anv_pipeline_cache
*cache
,
981 const void *key_data
, uint32_t key_size
,
982 const void *kernel_data
, uint32_t kernel_size
,
983 const void *constant_data
,
984 uint32_t constant_data_size
,
985 const struct brw_stage_prog_data
*prog_data
,
986 uint32_t prog_data_size
,
987 const struct anv_pipeline_bind_map
*bind_map
);
990 VK_LOADER_DATA _loader_data
;
992 VkAllocationCallbacks alloc
;
994 struct anv_instance
* instance
;
997 struct gen_device_info info
;
998 struct isl_device isl_dev
;
1001 bool can_chain_batches
;
1002 bool robust_buffer_access
;
1003 struct anv_device_extension_table enabled_extensions
;
1004 struct anv_device_dispatch_table dispatch
;
1006 pthread_mutex_t vma_mutex
;
1007 struct util_vma_heap vma_lo
;
1008 struct util_vma_heap vma_hi
;
1009 uint64_t vma_lo_available
;
1010 uint64_t vma_hi_available
;
1012 struct anv_bo_pool batch_bo_pool
;
1014 struct anv_bo_cache bo_cache
;
1016 struct anv_state_pool dynamic_state_pool
;
1017 struct anv_state_pool instruction_state_pool
;
1018 struct anv_state_pool binding_table_pool
;
1019 struct anv_state_pool surface_state_pool
;
1021 struct anv_bo workaround_bo
;
1022 struct anv_bo trivial_batch_bo
;
1023 struct anv_bo hiz_clear_bo
;
1025 struct anv_pipeline_cache default_pipeline_cache
;
1026 struct blorp_context blorp
;
1028 struct anv_state border_colors
;
1030 struct anv_queue queue
;
1032 struct anv_scratch_pool scratch_pool
;
1034 uint32_t default_mocs
;
1035 uint32_t external_mocs
;
1037 pthread_mutex_t mutex
;
1038 pthread_cond_t queue_submit
;
1042 static inline struct anv_state_pool
*
1043 anv_binding_table_pool(struct anv_device
*device
)
1045 if (device
->instance
->physicalDevice
.use_softpin
)
1046 return &device
->binding_table_pool
;
1048 return &device
->surface_state_pool
;
1051 static inline struct anv_state
1052 anv_binding_table_pool_alloc(struct anv_device
*device
) {
1053 if (device
->instance
->physicalDevice
.use_softpin
)
1054 return anv_state_pool_alloc(&device
->binding_table_pool
,
1055 device
->binding_table_pool
.block_size
, 0);
1057 return anv_state_pool_alloc_back(&device
->surface_state_pool
);
1061 anv_binding_table_pool_free(struct anv_device
*device
, struct anv_state state
) {
1062 anv_state_pool_free(anv_binding_table_pool(device
), state
);
1065 static inline uint32_t
1066 anv_mocs_for_bo(const struct anv_device
*device
, const struct anv_bo
*bo
)
1068 if (bo
->flags
& ANV_BO_EXTERNAL
)
1069 return device
->external_mocs
;
1071 return device
->default_mocs
;
1075 anv_state_flush(struct anv_device
*device
, struct anv_state state
)
1077 if (device
->info
.has_llc
)
1080 gen_flush_range(state
.map
, state
.alloc_size
);
1083 void anv_device_init_blorp(struct anv_device
*device
);
1084 void anv_device_finish_blorp(struct anv_device
*device
);
1086 VkResult
_anv_device_set_lost(struct anv_device
*device
,
1087 const char *file
, int line
,
1088 const char *msg
, ...);
1089 #define anv_device_set_lost(dev, ...) \
1090 _anv_device_set_lost(dev, __FILE__, __LINE__, __VA_ARGS__)
1093 anv_device_is_lost(struct anv_device
*device
)
1095 return unlikely(device
->_lost
);
1098 VkResult
anv_device_execbuf(struct anv_device
*device
,
1099 struct drm_i915_gem_execbuffer2
*execbuf
,
1100 struct anv_bo
**execbuf_bos
);
1101 VkResult
anv_device_query_status(struct anv_device
*device
);
1102 VkResult
anv_device_bo_busy(struct anv_device
*device
, struct anv_bo
*bo
);
1103 VkResult
anv_device_wait(struct anv_device
*device
, struct anv_bo
*bo
,
1106 void* anv_gem_mmap(struct anv_device
*device
,
1107 uint32_t gem_handle
, uint64_t offset
, uint64_t size
, uint32_t flags
);
1108 void anv_gem_munmap(void *p
, uint64_t size
);
1109 uint32_t anv_gem_create(struct anv_device
*device
, uint64_t size
);
1110 void anv_gem_close(struct anv_device
*device
, uint32_t gem_handle
);
1111 uint32_t anv_gem_userptr(struct anv_device
*device
, void *mem
, size_t size
);
1112 int anv_gem_busy(struct anv_device
*device
, uint32_t gem_handle
);
1113 int anv_gem_wait(struct anv_device
*device
, uint32_t gem_handle
, int64_t *timeout_ns
);
1114 int anv_gem_execbuffer(struct anv_device
*device
,
1115 struct drm_i915_gem_execbuffer2
*execbuf
);
1116 int anv_gem_set_tiling(struct anv_device
*device
, uint32_t gem_handle
,
1117 uint32_t stride
, uint32_t tiling
);
1118 int anv_gem_create_context(struct anv_device
*device
);
1119 bool anv_gem_has_context_priority(int fd
);
1120 int anv_gem_destroy_context(struct anv_device
*device
, int context
);
1121 int anv_gem_set_context_param(int fd
, int context
, uint32_t param
,
1123 int anv_gem_get_context_param(int fd
, int context
, uint32_t param
,
1125 int anv_gem_get_param(int fd
, uint32_t param
);
1126 int anv_gem_get_tiling(struct anv_device
*device
, uint32_t gem_handle
);
1127 bool anv_gem_get_bit6_swizzle(int fd
, uint32_t tiling
);
1128 int anv_gem_get_aperture(int fd
, uint64_t *size
);
1129 int anv_gem_gpu_get_reset_stats(struct anv_device
*device
,
1130 uint32_t *active
, uint32_t *pending
);
1131 int anv_gem_handle_to_fd(struct anv_device
*device
, uint32_t gem_handle
);
1132 int anv_gem_reg_read(struct anv_device
*device
,
1133 uint32_t offset
, uint64_t *result
);
1134 uint32_t anv_gem_fd_to_handle(struct anv_device
*device
, int fd
);
1135 int anv_gem_set_caching(struct anv_device
*device
, uint32_t gem_handle
, uint32_t caching
);
1136 int anv_gem_set_domain(struct anv_device
*device
, uint32_t gem_handle
,
1137 uint32_t read_domains
, uint32_t write_domain
);
1138 int anv_gem_sync_file_merge(struct anv_device
*device
, int fd1
, int fd2
);
1139 uint32_t anv_gem_syncobj_create(struct anv_device
*device
, uint32_t flags
);
1140 void anv_gem_syncobj_destroy(struct anv_device
*device
, uint32_t handle
);
1141 int anv_gem_syncobj_handle_to_fd(struct anv_device
*device
, uint32_t handle
);
1142 uint32_t anv_gem_syncobj_fd_to_handle(struct anv_device
*device
, int fd
);
1143 int anv_gem_syncobj_export_sync_file(struct anv_device
*device
,
1145 int anv_gem_syncobj_import_sync_file(struct anv_device
*device
,
1146 uint32_t handle
, int fd
);
1147 void anv_gem_syncobj_reset(struct anv_device
*device
, uint32_t handle
);
1148 bool anv_gem_supports_syncobj_wait(int fd
);
1149 int anv_gem_syncobj_wait(struct anv_device
*device
,
1150 uint32_t *handles
, uint32_t num_handles
,
1151 int64_t abs_timeout_ns
, bool wait_all
);
1153 bool anv_vma_alloc(struct anv_device
*device
, struct anv_bo
*bo
);
1154 void anv_vma_free(struct anv_device
*device
, struct anv_bo
*bo
);
1156 VkResult
anv_bo_init_new(struct anv_bo
*bo
, struct anv_device
*device
, uint64_t size
);
1158 struct anv_reloc_list
{
1159 uint32_t num_relocs
;
1160 uint32_t array_length
;
1161 struct drm_i915_gem_relocation_entry
* relocs
;
1162 struct anv_bo
** reloc_bos
;
1166 VkResult
anv_reloc_list_init(struct anv_reloc_list
*list
,
1167 const VkAllocationCallbacks
*alloc
);
1168 void anv_reloc_list_finish(struct anv_reloc_list
*list
,
1169 const VkAllocationCallbacks
*alloc
);
1171 VkResult
anv_reloc_list_add(struct anv_reloc_list
*list
,
1172 const VkAllocationCallbacks
*alloc
,
1173 uint32_t offset
, struct anv_bo
*target_bo
,
1176 struct anv_batch_bo
{
1177 /* Link in the anv_cmd_buffer.owned_batch_bos list */
1178 struct list_head link
;
1182 /* Bytes actually consumed in this batch BO */
1185 struct anv_reloc_list relocs
;
1189 const VkAllocationCallbacks
* alloc
;
1195 struct anv_reloc_list
* relocs
;
1197 /* This callback is called (with the associated user data) in the event
1198 * that the batch runs out of space.
1200 VkResult (*extend_cb
)(struct anv_batch
*, void *);
1204 * Current error status of the command buffer. Used to track inconsistent
1205 * or incomplete command buffer states that are the consequence of run-time
1206 * errors such as out of memory scenarios. We want to track this in the
1207 * batch because the command buffer object is not visible to some parts
1213 void *anv_batch_emit_dwords(struct anv_batch
*batch
, int num_dwords
);
1214 void anv_batch_emit_batch(struct anv_batch
*batch
, struct anv_batch
*other
);
1215 uint64_t anv_batch_emit_reloc(struct anv_batch
*batch
,
1216 void *location
, struct anv_bo
*bo
, uint32_t offset
);
1217 VkResult
anv_device_submit_simple_batch(struct anv_device
*device
,
1218 struct anv_batch
*batch
);
1220 static inline VkResult
1221 anv_batch_set_error(struct anv_batch
*batch
, VkResult error
)
1223 assert(error
!= VK_SUCCESS
);
1224 if (batch
->status
== VK_SUCCESS
)
1225 batch
->status
= error
;
1226 return batch
->status
;
1230 anv_batch_has_error(struct anv_batch
*batch
)
1232 return batch
->status
!= VK_SUCCESS
;
1235 struct anv_address
{
1240 #define ANV_NULL_ADDRESS ((struct anv_address) { NULL, 0 })
1243 anv_address_is_null(struct anv_address addr
)
1245 return addr
.bo
== NULL
&& addr
.offset
== 0;
1248 static inline uint64_t
1249 anv_address_physical(struct anv_address addr
)
1251 if (addr
.bo
&& (addr
.bo
->flags
& EXEC_OBJECT_PINNED
))
1252 return gen_canonical_address(addr
.bo
->offset
+ addr
.offset
);
1254 return gen_canonical_address(addr
.offset
);
1257 static inline struct anv_address
1258 anv_address_add(struct anv_address addr
, uint64_t offset
)
1260 addr
.offset
+= offset
;
1265 write_reloc(const struct anv_device
*device
, void *p
, uint64_t v
, bool flush
)
1267 unsigned reloc_size
= 0;
1268 if (device
->info
.gen
>= 8) {
1269 reloc_size
= sizeof(uint64_t);
1270 *(uint64_t *)p
= gen_canonical_address(v
);
1272 reloc_size
= sizeof(uint32_t);
1276 if (flush
&& !device
->info
.has_llc
)
1277 gen_flush_range(p
, reloc_size
);
1280 static inline uint64_t
1281 _anv_combine_address(struct anv_batch
*batch
, void *location
,
1282 const struct anv_address address
, uint32_t delta
)
1284 if (address
.bo
== NULL
) {
1285 return address
.offset
+ delta
;
1287 assert(batch
->start
<= location
&& location
< batch
->end
);
1289 return anv_batch_emit_reloc(batch
, location
, address
.bo
, address
.offset
+ delta
);
1293 #define __gen_address_type struct anv_address
1294 #define __gen_user_data struct anv_batch
1295 #define __gen_combine_address _anv_combine_address
1297 /* Wrapper macros needed to work around preprocessor argument issues. In
1298 * particular, arguments don't get pre-evaluated if they are concatenated.
1299 * This means that, if you pass GENX(3DSTATE_PS) into the emit macro, the
1300 * GENX macro won't get evaluated if the emit macro contains "cmd ## foo".
1301 * We can work around this easily enough with these helpers.
1303 #define __anv_cmd_length(cmd) cmd ## _length
1304 #define __anv_cmd_length_bias(cmd) cmd ## _length_bias
1305 #define __anv_cmd_header(cmd) cmd ## _header
1306 #define __anv_cmd_pack(cmd) cmd ## _pack
1307 #define __anv_reg_num(reg) reg ## _num
1309 #define anv_pack_struct(dst, struc, ...) do { \
1310 struct struc __template = { \
1313 __anv_cmd_pack(struc)(NULL, dst, &__template); \
1314 VG(VALGRIND_CHECK_MEM_IS_DEFINED(dst, __anv_cmd_length(struc) * 4)); \
1317 #define anv_batch_emitn(batch, n, cmd, ...) ({ \
1318 void *__dst = anv_batch_emit_dwords(batch, n); \
1320 struct cmd __template = { \
1321 __anv_cmd_header(cmd), \
1322 .DWordLength = n - __anv_cmd_length_bias(cmd), \
1325 __anv_cmd_pack(cmd)(batch, __dst, &__template); \
1330 #define anv_batch_emit_merge(batch, dwords0, dwords1) \
1334 STATIC_ASSERT(ARRAY_SIZE(dwords0) == ARRAY_SIZE(dwords1)); \
1335 dw = anv_batch_emit_dwords((batch), ARRAY_SIZE(dwords0)); \
1338 for (uint32_t i = 0; i < ARRAY_SIZE(dwords0); i++) \
1339 dw[i] = (dwords0)[i] | (dwords1)[i]; \
1340 VG(VALGRIND_CHECK_MEM_IS_DEFINED(dw, ARRAY_SIZE(dwords0) * 4));\
1343 #define anv_batch_emit(batch, cmd, name) \
1344 for (struct cmd name = { __anv_cmd_header(cmd) }, \
1345 *_dst = anv_batch_emit_dwords(batch, __anv_cmd_length(cmd)); \
1346 __builtin_expect(_dst != NULL, 1); \
1347 ({ __anv_cmd_pack(cmd)(batch, _dst, &name); \
1348 VG(VALGRIND_CHECK_MEM_IS_DEFINED(_dst, __anv_cmd_length(cmd) * 4)); \
1352 /* MEMORY_OBJECT_CONTROL_STATE:
1353 * .GraphicsDataTypeGFDT = 0,
1354 * .LLCCacheabilityControlLLCCC = 0,
1355 * .L3CacheabilityControlL3CC = 1,
1359 /* MEMORY_OBJECT_CONTROL_STATE:
1360 * .LLCeLLCCacheabilityControlLLCCC = 0,
1361 * .L3CacheabilityControlL3CC = 1,
1363 #define GEN75_MOCS 1
1365 /* MEMORY_OBJECT_CONTROL_STATE:
1366 * .MemoryTypeLLCeLLCCacheabilityControl = WB,
1367 * .TargetCache = L3DefertoPATforLLCeLLCselection,
1368 * .AgeforQUADLRU = 0
1370 #define GEN8_MOCS 0x78
1372 /* MEMORY_OBJECT_CONTROL_STATE:
1373 * .MemoryTypeLLCeLLCCacheabilityControl = UCwithFenceifcoherentcycle,
1374 * .TargetCache = L3DefertoPATforLLCeLLCselection,
1375 * .AgeforQUADLRU = 0
1377 #define GEN8_EXTERNAL_MOCS 0x18
1379 /* Skylake: MOCS is now an index into an array of 62 different caching
1380 * configurations programmed by the kernel.
1383 /* TC=LLC/eLLC, LeCC=WB, LRUM=3, L3CC=WB */
1386 /* TC=LLC/eLLC, LeCC=WB, LRUM=3, L3CC=WB */
1387 #define GEN9_EXTERNAL_MOCS 1
1389 /* Cannonlake MOCS defines are duplicates of Skylake MOCS defines. */
1390 #define GEN10_MOCS GEN9_MOCS
1391 #define GEN10_EXTERNAL_MOCS GEN9_EXTERNAL_MOCS
1393 /* Ice Lake MOCS defines are duplicates of Skylake MOCS defines. */
1394 #define GEN11_MOCS GEN9_MOCS
1395 #define GEN11_EXTERNAL_MOCS GEN9_EXTERNAL_MOCS
1397 struct anv_device_memory
{
1399 struct anv_memory_type
* type
;
1400 VkDeviceSize map_size
;
1405 * Header for Vertex URB Entry (VUE)
1407 struct anv_vue_header
{
1409 uint32_t RTAIndex
; /* RenderTargetArrayIndex */
1410 uint32_t ViewportIndex
;
1414 struct anv_descriptor_set_binding_layout
{
1416 /* The type of the descriptors in this binding */
1417 VkDescriptorType type
;
1420 /* Number of array elements in this binding */
1421 uint16_t array_size
;
1423 /* Index into the flattend descriptor set */
1424 uint16_t descriptor_index
;
1426 /* Index into the dynamic state array for a dynamic buffer */
1427 int16_t dynamic_offset_index
;
1429 /* Index into the descriptor set buffer views */
1430 int16_t buffer_index
;
1433 /* Index into the binding table for the associated surface */
1434 int16_t surface_index
;
1436 /* Index into the sampler table for the associated sampler */
1437 int16_t sampler_index
;
1439 /* Index into the image table for the associated image */
1440 int16_t image_index
;
1441 } stage
[MESA_SHADER_STAGES
];
1443 /* Immutable samplers (or NULL if no immutable samplers) */
1444 struct anv_sampler
**immutable_samplers
;
1447 struct anv_descriptor_set_layout
{
1448 /* Descriptor set layouts can be destroyed at almost any time */
1451 /* Number of bindings in this descriptor set */
1452 uint16_t binding_count
;
1454 /* Total size of the descriptor set with room for all array entries */
1457 /* Shader stages affected by this descriptor set */
1458 uint16_t shader_stages
;
1460 /* Number of buffers in this descriptor set */
1461 uint16_t buffer_count
;
1463 /* Number of dynamic offsets used by this descriptor set */
1464 uint16_t dynamic_offset_count
;
1466 /* Bindings in this descriptor set */
1467 struct anv_descriptor_set_binding_layout binding
[0];
1471 anv_descriptor_set_layout_ref(struct anv_descriptor_set_layout
*layout
)
1473 assert(layout
&& layout
->ref_cnt
>= 1);
1474 p_atomic_inc(&layout
->ref_cnt
);
1478 anv_descriptor_set_layout_unref(struct anv_device
*device
,
1479 struct anv_descriptor_set_layout
*layout
)
1481 assert(layout
&& layout
->ref_cnt
>= 1);
1482 if (p_atomic_dec_zero(&layout
->ref_cnt
))
1483 vk_free(&device
->alloc
, layout
);
1486 struct anv_descriptor
{
1487 VkDescriptorType type
;
1491 VkImageLayout layout
;
1492 struct anv_image_view
*image_view
;
1493 struct anv_sampler
*sampler
;
1497 struct anv_buffer
*buffer
;
1502 struct anv_buffer_view
*buffer_view
;
1506 struct anv_descriptor_set
{
1507 struct anv_descriptor_set_layout
*layout
;
1509 uint32_t buffer_count
;
1510 struct anv_buffer_view
*buffer_views
;
1511 struct anv_descriptor descriptors
[0];
1514 struct anv_buffer_view
{
1515 enum isl_format format
; /**< VkBufferViewCreateInfo::format */
1516 uint64_t range
; /**< VkBufferViewCreateInfo::range */
1518 struct anv_address address
;
1520 struct anv_state surface_state
;
1521 struct anv_state storage_surface_state
;
1522 struct anv_state writeonly_storage_surface_state
;
1524 struct brw_image_param storage_image_param
;
1527 struct anv_push_descriptor_set
{
1528 struct anv_descriptor_set set
;
1530 /* Put this field right behind anv_descriptor_set so it fills up the
1531 * descriptors[0] field. */
1532 struct anv_descriptor descriptors
[MAX_PUSH_DESCRIPTORS
];
1533 struct anv_buffer_view buffer_views
[MAX_PUSH_DESCRIPTORS
];
1536 struct anv_descriptor_pool
{
1541 struct anv_state_stream surface_state_stream
;
1542 void *surface_state_free_list
;
1547 enum anv_descriptor_template_entry_type
{
1548 ANV_DESCRIPTOR_TEMPLATE_ENTRY_TYPE_IMAGE
,
1549 ANV_DESCRIPTOR_TEMPLATE_ENTRY_TYPE_BUFFER
,
1550 ANV_DESCRIPTOR_TEMPLATE_ENTRY_TYPE_BUFFER_VIEW
1553 struct anv_descriptor_template_entry
{
1554 /* The type of descriptor in this entry */
1555 VkDescriptorType type
;
1557 /* Binding in the descriptor set */
1560 /* Offset at which to write into the descriptor set binding */
1561 uint32_t array_element
;
1563 /* Number of elements to write into the descriptor set binding */
1564 uint32_t array_count
;
1566 /* Offset into the user provided data */
1569 /* Stride between elements into the user provided data */
1573 struct anv_descriptor_update_template
{
1574 VkPipelineBindPoint bind_point
;
1576 /* The descriptor set this template corresponds to. This value is only
1577 * valid if the template was created with the templateType
1578 * VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR.
1582 /* Number of entries in this template */
1583 uint32_t entry_count
;
1585 /* Entries of the template */
1586 struct anv_descriptor_template_entry entries
[0];
1590 anv_descriptor_set_layout_size(const struct anv_descriptor_set_layout
*layout
);
1593 anv_descriptor_set_write_image_view(struct anv_descriptor_set
*set
,
1594 const struct gen_device_info
* const devinfo
,
1595 const VkDescriptorImageInfo
* const info
,
1596 VkDescriptorType type
,
1601 anv_descriptor_set_write_buffer_view(struct anv_descriptor_set
*set
,
1602 VkDescriptorType type
,
1603 struct anv_buffer_view
*buffer_view
,
1608 anv_descriptor_set_write_buffer(struct anv_descriptor_set
*set
,
1609 struct anv_device
*device
,
1610 struct anv_state_stream
*alloc_stream
,
1611 VkDescriptorType type
,
1612 struct anv_buffer
*buffer
,
1615 VkDeviceSize offset
,
1616 VkDeviceSize range
);
1619 anv_descriptor_set_write_template(struct anv_descriptor_set
*set
,
1620 struct anv_device
*device
,
1621 struct anv_state_stream
*alloc_stream
,
1622 const struct anv_descriptor_update_template
*template,
1626 anv_descriptor_set_create(struct anv_device
*device
,
1627 struct anv_descriptor_pool
*pool
,
1628 struct anv_descriptor_set_layout
*layout
,
1629 struct anv_descriptor_set
**out_set
);
1632 anv_descriptor_set_destroy(struct anv_device
*device
,
1633 struct anv_descriptor_pool
*pool
,
1634 struct anv_descriptor_set
*set
);
1636 #define ANV_DESCRIPTOR_SET_SHADER_CONSTANTS (UINT8_MAX - 1)
1637 #define ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS UINT8_MAX
1639 struct anv_pipeline_binding
{
1640 /* The descriptor set this surface corresponds to. The special value of
1641 * ANV_DESCRIPTOR_SET_COLOR_ATTACHMENTS indicates that the offset refers
1642 * to a color attachment and not a regular descriptor.
1646 /* Binding in the descriptor set */
1649 /* Index in the binding */
1652 /* Plane in the binding index */
1655 /* Input attachment index (relative to the subpass) */
1656 uint8_t input_attachment_index
;
1658 /* For a storage image, whether it is write-only */
1662 struct anv_pipeline_layout
{
1664 struct anv_descriptor_set_layout
*layout
;
1665 uint32_t dynamic_offset_start
;
1671 bool has_dynamic_offsets
;
1672 } stage
[MESA_SHADER_STAGES
];
1674 unsigned char sha1
[20];
1678 struct anv_device
* device
;
1681 VkBufferUsageFlags usage
;
1683 /* Set when bound */
1684 struct anv_address address
;
1687 static inline uint64_t
1688 anv_buffer_get_range(struct anv_buffer
*buffer
, uint64_t offset
, uint64_t range
)
1690 assert(offset
<= buffer
->size
);
1691 if (range
== VK_WHOLE_SIZE
) {
1692 return buffer
->size
- offset
;
1694 assert(range
+ offset
>= range
);
1695 assert(range
+ offset
<= buffer
->size
);
1700 enum anv_cmd_dirty_bits
{
1701 ANV_CMD_DIRTY_DYNAMIC_VIEWPORT
= 1 << 0, /* VK_DYNAMIC_STATE_VIEWPORT */
1702 ANV_CMD_DIRTY_DYNAMIC_SCISSOR
= 1 << 1, /* VK_DYNAMIC_STATE_SCISSOR */
1703 ANV_CMD_DIRTY_DYNAMIC_LINE_WIDTH
= 1 << 2, /* VK_DYNAMIC_STATE_LINE_WIDTH */
1704 ANV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS
= 1 << 3, /* VK_DYNAMIC_STATE_DEPTH_BIAS */
1705 ANV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS
= 1 << 4, /* VK_DYNAMIC_STATE_BLEND_CONSTANTS */
1706 ANV_CMD_DIRTY_DYNAMIC_DEPTH_BOUNDS
= 1 << 5, /* VK_DYNAMIC_STATE_DEPTH_BOUNDS */
1707 ANV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK
= 1 << 6, /* VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK */
1708 ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK
= 1 << 7, /* VK_DYNAMIC_STATE_STENCIL_WRITE_MASK */
1709 ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE
= 1 << 8, /* VK_DYNAMIC_STATE_STENCIL_REFERENCE */
1710 ANV_CMD_DIRTY_DYNAMIC_ALL
= (1 << 9) - 1,
1711 ANV_CMD_DIRTY_PIPELINE
= 1 << 9,
1712 ANV_CMD_DIRTY_INDEX_BUFFER
= 1 << 10,
1713 ANV_CMD_DIRTY_RENDER_TARGETS
= 1 << 11,
1715 typedef uint32_t anv_cmd_dirty_mask_t
;
1717 enum anv_pipe_bits
{
1718 ANV_PIPE_DEPTH_CACHE_FLUSH_BIT
= (1 << 0),
1719 ANV_PIPE_STALL_AT_SCOREBOARD_BIT
= (1 << 1),
1720 ANV_PIPE_STATE_CACHE_INVALIDATE_BIT
= (1 << 2),
1721 ANV_PIPE_CONSTANT_CACHE_INVALIDATE_BIT
= (1 << 3),
1722 ANV_PIPE_VF_CACHE_INVALIDATE_BIT
= (1 << 4),
1723 ANV_PIPE_DATA_CACHE_FLUSH_BIT
= (1 << 5),
1724 ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT
= (1 << 10),
1725 ANV_PIPE_INSTRUCTION_CACHE_INVALIDATE_BIT
= (1 << 11),
1726 ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT
= (1 << 12),
1727 ANV_PIPE_DEPTH_STALL_BIT
= (1 << 13),
1728 ANV_PIPE_CS_STALL_BIT
= (1 << 20),
1730 /* This bit does not exist directly in PIPE_CONTROL. Instead it means that
1731 * a flush has happened but not a CS stall. The next time we do any sort
1732 * of invalidation we need to insert a CS stall at that time. Otherwise,
1733 * we would have to CS stall on every flush which could be bad.
1735 ANV_PIPE_NEEDS_CS_STALL_BIT
= (1 << 21),
1737 /* This bit does not exist directly in PIPE_CONTROL. It means that render
1738 * target operations are ongoing. Some operations like copies on the
1739 * command streamer might need to be aware of this to trigger the
1740 * appropriate stall before they can proceed with the copy.
1742 ANV_PIPE_RENDER_TARGET_WRITES
= (1 << 22),
1745 #define ANV_PIPE_FLUSH_BITS ( \
1746 ANV_PIPE_DEPTH_CACHE_FLUSH_BIT | \
1747 ANV_PIPE_DATA_CACHE_FLUSH_BIT | \
1748 ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT)
1750 #define ANV_PIPE_STALL_BITS ( \
1751 ANV_PIPE_STALL_AT_SCOREBOARD_BIT | \
1752 ANV_PIPE_DEPTH_STALL_BIT | \
1753 ANV_PIPE_CS_STALL_BIT)
1755 #define ANV_PIPE_INVALIDATE_BITS ( \
1756 ANV_PIPE_STATE_CACHE_INVALIDATE_BIT | \
1757 ANV_PIPE_CONSTANT_CACHE_INVALIDATE_BIT | \
1758 ANV_PIPE_VF_CACHE_INVALIDATE_BIT | \
1759 ANV_PIPE_DATA_CACHE_FLUSH_BIT | \
1760 ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT | \
1761 ANV_PIPE_INSTRUCTION_CACHE_INVALIDATE_BIT)
1763 static inline enum anv_pipe_bits
1764 anv_pipe_flush_bits_for_access_flags(VkAccessFlags flags
)
1766 enum anv_pipe_bits pipe_bits
= 0;
1769 for_each_bit(b
, flags
) {
1770 switch ((VkAccessFlagBits
)(1 << b
)) {
1771 case VK_ACCESS_SHADER_WRITE_BIT
:
1772 pipe_bits
|= ANV_PIPE_DATA_CACHE_FLUSH_BIT
;
1774 case VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
:
1775 pipe_bits
|= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT
;
1777 case VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
:
1778 pipe_bits
|= ANV_PIPE_DEPTH_CACHE_FLUSH_BIT
;
1780 case VK_ACCESS_TRANSFER_WRITE_BIT
:
1781 pipe_bits
|= ANV_PIPE_RENDER_TARGET_CACHE_FLUSH_BIT
;
1782 pipe_bits
|= ANV_PIPE_DEPTH_CACHE_FLUSH_BIT
;
1784 case VK_ACCESS_MEMORY_WRITE_BIT
:
1785 pipe_bits
|= ANV_PIPE_FLUSH_BITS
;
1788 break; /* Nothing to do */
1795 static inline enum anv_pipe_bits
1796 anv_pipe_invalidate_bits_for_access_flags(VkAccessFlags flags
)
1798 enum anv_pipe_bits pipe_bits
= 0;
1801 for_each_bit(b
, flags
) {
1802 switch ((VkAccessFlagBits
)(1 << b
)) {
1803 case VK_ACCESS_INDIRECT_COMMAND_READ_BIT
:
1804 case VK_ACCESS_INDEX_READ_BIT
:
1805 case VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
:
1806 pipe_bits
|= ANV_PIPE_VF_CACHE_INVALIDATE_BIT
;
1808 case VK_ACCESS_UNIFORM_READ_BIT
:
1809 pipe_bits
|= ANV_PIPE_CONSTANT_CACHE_INVALIDATE_BIT
;
1810 pipe_bits
|= ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT
;
1812 case VK_ACCESS_SHADER_READ_BIT
:
1813 case VK_ACCESS_INPUT_ATTACHMENT_READ_BIT
:
1814 case VK_ACCESS_TRANSFER_READ_BIT
:
1815 pipe_bits
|= ANV_PIPE_TEXTURE_CACHE_INVALIDATE_BIT
;
1817 case VK_ACCESS_MEMORY_READ_BIT
:
1818 pipe_bits
|= ANV_PIPE_INVALIDATE_BITS
;
1820 case VK_ACCESS_MEMORY_WRITE_BIT
:
1821 pipe_bits
|= ANV_PIPE_FLUSH_BITS
;
1824 break; /* Nothing to do */
1831 #define VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV ( \
1832 VK_IMAGE_ASPECT_COLOR_BIT | \
1833 VK_IMAGE_ASPECT_PLANE_0_BIT | \
1834 VK_IMAGE_ASPECT_PLANE_1_BIT | \
1835 VK_IMAGE_ASPECT_PLANE_2_BIT)
1836 #define VK_IMAGE_ASPECT_PLANES_BITS_ANV ( \
1837 VK_IMAGE_ASPECT_PLANE_0_BIT | \
1838 VK_IMAGE_ASPECT_PLANE_1_BIT | \
1839 VK_IMAGE_ASPECT_PLANE_2_BIT)
1841 struct anv_vertex_binding
{
1842 struct anv_buffer
* buffer
;
1843 VkDeviceSize offset
;
1846 #define ANV_PARAM_PUSH(offset) ((1 << 16) | (uint32_t)(offset))
1847 #define ANV_PARAM_PUSH_OFFSET(param) ((param) & 0xffff)
1849 struct anv_push_constants
{
1850 /* Current allocated size of this push constants data structure.
1851 * Because a decent chunk of it may not be used (images on SKL, for
1852 * instance), we won't actually allocate the entire structure up-front.
1856 /* Push constant data provided by the client through vkPushConstants */
1857 uint8_t client_data
[MAX_PUSH_CONSTANTS_SIZE
];
1859 /* Used for vkCmdDispatchBase */
1860 uint32_t base_work_group_id
[3];
1862 /* Image data for image_load_store on pre-SKL */
1863 struct brw_image_param images
[MAX_IMAGES
];
1866 struct anv_dynamic_state
{
1869 VkViewport viewports
[MAX_VIEWPORTS
];
1874 VkRect2D scissors
[MAX_SCISSORS
];
1885 float blend_constants
[4];
1895 } stencil_compare_mask
;
1900 } stencil_write_mask
;
1905 } stencil_reference
;
1908 extern const struct anv_dynamic_state default_dynamic_state
;
1910 void anv_dynamic_state_copy(struct anv_dynamic_state
*dest
,
1911 const struct anv_dynamic_state
*src
,
1912 uint32_t copy_mask
);
1914 struct anv_surface_state
{
1915 struct anv_state state
;
1916 /** Address of the surface referred to by this state
1918 * This address is relative to the start of the BO.
1920 struct anv_address address
;
1921 /* Address of the aux surface, if any
1923 * This field is ANV_NULL_ADDRESS if and only if no aux surface exists.
1925 * With the exception of gen8, the bottom 12 bits of this address' offset
1926 * include extra aux information.
1928 struct anv_address aux_address
;
1929 /* Address of the clear color, if any
1931 * This address is relative to the start of the BO.
1933 struct anv_address clear_address
;
1937 * Attachment state when recording a renderpass instance.
1939 * The clear value is valid only if there exists a pending clear.
1941 struct anv_attachment_state
{
1942 enum isl_aux_usage aux_usage
;
1943 enum isl_aux_usage input_aux_usage
;
1944 struct anv_surface_state color
;
1945 struct anv_surface_state input
;
1947 VkImageLayout current_layout
;
1948 VkImageAspectFlags pending_clear_aspects
;
1949 VkImageAspectFlags pending_load_aspects
;
1951 VkClearValue clear_value
;
1952 bool clear_color_is_zero_one
;
1953 bool clear_color_is_zero
;
1955 /* When multiview is active, attachments with a renderpass clear
1956 * operation have their respective layers cleared on the first
1957 * subpass that uses them, and only in that subpass. We keep track
1958 * of this using a bitfield to indicate which layers of an attachment
1959 * have not been cleared yet when multiview is active.
1961 uint32_t pending_clear_views
;
1964 /** State tracking for particular pipeline bind point
1966 * This struct is the base struct for anv_cmd_graphics_state and
1967 * anv_cmd_compute_state. These are used to track state which is bound to a
1968 * particular type of pipeline. Generic state that applies per-stage such as
1969 * binding table offsets and push constants is tracked generically with a
1970 * per-stage array in anv_cmd_state.
1972 struct anv_cmd_pipeline_state
{
1973 struct anv_pipeline
*pipeline
;
1974 struct anv_pipeline_layout
*layout
;
1976 struct anv_descriptor_set
*descriptors
[MAX_SETS
];
1977 uint32_t dynamic_offsets
[MAX_DYNAMIC_BUFFERS
];
1979 struct anv_push_descriptor_set
*push_descriptors
[MAX_SETS
];
1982 /** State tracking for graphics pipeline
1984 * This has anv_cmd_pipeline_state as a base struct to track things which get
1985 * bound to a graphics pipeline. Along with general pipeline bind point state
1986 * which is in the anv_cmd_pipeline_state base struct, it also contains other
1987 * state which is graphics-specific.
1989 struct anv_cmd_graphics_state
{
1990 struct anv_cmd_pipeline_state base
;
1992 anv_cmd_dirty_mask_t dirty
;
1995 struct anv_dynamic_state dynamic
;
1998 struct anv_buffer
*index_buffer
;
1999 uint32_t index_type
; /**< 3DSTATE_INDEX_BUFFER.IndexFormat */
2000 uint32_t index_offset
;
2004 /** State tracking for compute pipeline
2006 * This has anv_cmd_pipeline_state as a base struct to track things which get
2007 * bound to a compute pipeline. Along with general pipeline bind point state
2008 * which is in the anv_cmd_pipeline_state base struct, it also contains other
2009 * state which is compute-specific.
2011 struct anv_cmd_compute_state
{
2012 struct anv_cmd_pipeline_state base
;
2014 bool pipeline_dirty
;
2016 struct anv_address num_workgroups
;
2019 /** State required while building cmd buffer */
2020 struct anv_cmd_state
{
2021 /* PIPELINE_SELECT.PipelineSelection */
2022 uint32_t current_pipeline
;
2023 const struct gen_l3_config
* current_l3_config
;
2025 struct anv_cmd_graphics_state gfx
;
2026 struct anv_cmd_compute_state compute
;
2028 enum anv_pipe_bits pending_pipe_bits
;
2029 VkShaderStageFlags descriptors_dirty
;
2030 VkShaderStageFlags push_constants_dirty
;
2032 struct anv_framebuffer
* framebuffer
;
2033 struct anv_render_pass
* pass
;
2034 struct anv_subpass
* subpass
;
2035 VkRect2D render_area
;
2036 uint32_t restart_index
;
2037 struct anv_vertex_binding vertex_bindings
[MAX_VBS
];
2038 VkShaderStageFlags push_constant_stages
;
2039 struct anv_push_constants
* push_constants
[MESA_SHADER_STAGES
];
2040 struct anv_state binding_tables
[MESA_SHADER_STAGES
];
2041 struct anv_state samplers
[MESA_SHADER_STAGES
];
2044 * Whether or not the gen8 PMA fix is enabled. We ensure that, at the top
2045 * of any command buffer it is disabled by disabling it in EndCommandBuffer
2046 * and before invoking the secondary in ExecuteCommands.
2048 bool pma_fix_enabled
;
2051 * Whether or not we know for certain that HiZ is enabled for the current
2052 * subpass. If, for whatever reason, we are unsure as to whether HiZ is
2053 * enabled or not, this will be false.
2058 * Array length is anv_cmd_state::pass::attachment_count. Array content is
2059 * valid only when recording a render pass instance.
2061 struct anv_attachment_state
* attachments
;
2064 * Surface states for color render targets. These are stored in a single
2065 * flat array. For depth-stencil attachments, the surface state is simply
2068 struct anv_state render_pass_states
;
2071 * A null surface state of the right size to match the framebuffer. This
2072 * is one of the states in render_pass_states.
2074 struct anv_state null_surface_state
;
2077 struct anv_cmd_pool
{
2078 VkAllocationCallbacks alloc
;
2079 struct list_head cmd_buffers
;
2082 #define ANV_CMD_BUFFER_BATCH_SIZE 8192
2084 enum anv_cmd_buffer_exec_mode
{
2085 ANV_CMD_BUFFER_EXEC_MODE_PRIMARY
,
2086 ANV_CMD_BUFFER_EXEC_MODE_EMIT
,
2087 ANV_CMD_BUFFER_EXEC_MODE_GROW_AND_EMIT
,
2088 ANV_CMD_BUFFER_EXEC_MODE_CHAIN
,
2089 ANV_CMD_BUFFER_EXEC_MODE_COPY_AND_CHAIN
,
2092 struct anv_cmd_buffer
{
2093 VK_LOADER_DATA _loader_data
;
2095 struct anv_device
* device
;
2097 struct anv_cmd_pool
* pool
;
2098 struct list_head pool_link
;
2100 struct anv_batch batch
;
2102 /* Fields required for the actual chain of anv_batch_bo's.
2104 * These fields are initialized by anv_cmd_buffer_init_batch_bo_chain().
2106 struct list_head batch_bos
;
2107 enum anv_cmd_buffer_exec_mode exec_mode
;
2109 /* A vector of anv_batch_bo pointers for every batch or surface buffer
2110 * referenced by this command buffer
2112 * initialized by anv_cmd_buffer_init_batch_bo_chain()
2114 struct u_vector seen_bbos
;
2116 /* A vector of int32_t's for every block of binding tables.
2118 * initialized by anv_cmd_buffer_init_batch_bo_chain()
2120 struct u_vector bt_block_states
;
2123 struct anv_reloc_list surface_relocs
;
2124 /** Last seen surface state block pool center bo offset */
2125 uint32_t last_ss_pool_center
;
2127 /* Serial for tracking buffer completion */
2130 /* Stream objects for storing temporary data */
2131 struct anv_state_stream surface_state_stream
;
2132 struct anv_state_stream dynamic_state_stream
;
2134 VkCommandBufferUsageFlags usage_flags
;
2135 VkCommandBufferLevel level
;
2137 struct anv_cmd_state state
;
2140 VkResult
anv_cmd_buffer_init_batch_bo_chain(struct anv_cmd_buffer
*cmd_buffer
);
2141 void anv_cmd_buffer_fini_batch_bo_chain(struct anv_cmd_buffer
*cmd_buffer
);
2142 void anv_cmd_buffer_reset_batch_bo_chain(struct anv_cmd_buffer
*cmd_buffer
);
2143 void anv_cmd_buffer_end_batch_buffer(struct anv_cmd_buffer
*cmd_buffer
);
2144 void anv_cmd_buffer_add_secondary(struct anv_cmd_buffer
*primary
,
2145 struct anv_cmd_buffer
*secondary
);
2146 void anv_cmd_buffer_prepare_execbuf(struct anv_cmd_buffer
*cmd_buffer
);
2147 VkResult
anv_cmd_buffer_execbuf(struct anv_device
*device
,
2148 struct anv_cmd_buffer
*cmd_buffer
,
2149 const VkSemaphore
*in_semaphores
,
2150 uint32_t num_in_semaphores
,
2151 const VkSemaphore
*out_semaphores
,
2152 uint32_t num_out_semaphores
,
2155 VkResult
anv_cmd_buffer_reset(struct anv_cmd_buffer
*cmd_buffer
);
2158 anv_cmd_buffer_ensure_push_constants_size(struct anv_cmd_buffer
*cmd_buffer
,
2159 gl_shader_stage stage
, uint32_t size
);
2160 #define anv_cmd_buffer_ensure_push_constant_field(cmd_buffer, stage, field) \
2161 anv_cmd_buffer_ensure_push_constants_size(cmd_buffer, stage, \
2162 (offsetof(struct anv_push_constants, field) + \
2163 sizeof(cmd_buffer->state.push_constants[0]->field)))
2165 struct anv_state
anv_cmd_buffer_emit_dynamic(struct anv_cmd_buffer
*cmd_buffer
,
2166 const void *data
, uint32_t size
, uint32_t alignment
);
2167 struct anv_state
anv_cmd_buffer_merge_dynamic(struct anv_cmd_buffer
*cmd_buffer
,
2168 uint32_t *a
, uint32_t *b
,
2169 uint32_t dwords
, uint32_t alignment
);
2172 anv_cmd_buffer_surface_base_address(struct anv_cmd_buffer
*cmd_buffer
);
2174 anv_cmd_buffer_alloc_binding_table(struct anv_cmd_buffer
*cmd_buffer
,
2175 uint32_t entries
, uint32_t *state_offset
);
2177 anv_cmd_buffer_alloc_surface_state(struct anv_cmd_buffer
*cmd_buffer
);
2179 anv_cmd_buffer_alloc_dynamic_state(struct anv_cmd_buffer
*cmd_buffer
,
2180 uint32_t size
, uint32_t alignment
);
2183 anv_cmd_buffer_new_binding_table_block(struct anv_cmd_buffer
*cmd_buffer
);
2185 void gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer
*cmd_buffer
);
2186 void gen8_cmd_buffer_emit_depth_viewport(struct anv_cmd_buffer
*cmd_buffer
,
2187 bool depth_clamp_enable
);
2188 void gen7_cmd_buffer_emit_scissor(struct anv_cmd_buffer
*cmd_buffer
);
2190 void anv_cmd_buffer_setup_attachments(struct anv_cmd_buffer
*cmd_buffer
,
2191 struct anv_render_pass
*pass
,
2192 struct anv_framebuffer
*framebuffer
,
2193 const VkClearValue
*clear_values
);
2195 void anv_cmd_buffer_emit_state_base_address(struct anv_cmd_buffer
*cmd_buffer
);
2198 anv_cmd_buffer_push_constants(struct anv_cmd_buffer
*cmd_buffer
,
2199 gl_shader_stage stage
);
2201 anv_cmd_buffer_cs_push_constants(struct anv_cmd_buffer
*cmd_buffer
);
2203 void anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer
*cmd_buffer
);
2205 const struct anv_image_view
*
2206 anv_cmd_buffer_get_depth_stencil_view(const struct anv_cmd_buffer
*cmd_buffer
);
2209 anv_cmd_buffer_alloc_blorp_binding_table(struct anv_cmd_buffer
*cmd_buffer
,
2210 uint32_t num_entries
,
2211 uint32_t *state_offset
,
2212 struct anv_state
*bt_state
);
2214 void anv_cmd_buffer_dump(struct anv_cmd_buffer
*cmd_buffer
);
2216 enum anv_fence_type
{
2217 ANV_FENCE_TYPE_NONE
= 0,
2219 ANV_FENCE_TYPE_SYNCOBJ
,
2223 enum anv_bo_fence_state
{
2224 /** Indicates that this is a new (or newly reset fence) */
2225 ANV_BO_FENCE_STATE_RESET
,
2227 /** Indicates that this fence has been submitted to the GPU but is still
2228 * (as far as we know) in use by the GPU.
2230 ANV_BO_FENCE_STATE_SUBMITTED
,
2232 ANV_BO_FENCE_STATE_SIGNALED
,
2235 struct anv_fence_impl
{
2236 enum anv_fence_type type
;
2239 /** Fence implementation for BO fences
2241 * These fences use a BO and a set of CPU-tracked state flags. The BO
2242 * is added to the object list of the last execbuf call in a QueueSubmit
2243 * and is marked EXEC_WRITE. The state flags track when the BO has been
2244 * submitted to the kernel. We need to do this because Vulkan lets you
2245 * wait on a fence that has not yet been submitted and I915_GEM_BUSY
2246 * will say it's idle in this case.
2250 enum anv_bo_fence_state state
;
2253 /** DRM syncobj handle for syncobj-based fences */
2257 struct wsi_fence
*fence_wsi
;
2262 /* Permanent fence state. Every fence has some form of permanent state
2263 * (type != ANV_SEMAPHORE_TYPE_NONE). This may be a BO to fence on (for
2264 * cross-process fences) or it could just be a dummy for use internally.
2266 struct anv_fence_impl permanent
;
2268 /* Temporary fence state. A fence *may* have temporary state. That state
2269 * is added to the fence by an import operation and is reset back to
2270 * ANV_SEMAPHORE_TYPE_NONE when the fence is reset. A fence with temporary
2271 * state cannot be signaled because the fence must already be signaled
2272 * before the temporary state can be exported from the fence in the other
2273 * process and imported here.
2275 struct anv_fence_impl temporary
;
2280 struct anv_state state
;
2283 enum anv_semaphore_type
{
2284 ANV_SEMAPHORE_TYPE_NONE
= 0,
2285 ANV_SEMAPHORE_TYPE_DUMMY
,
2286 ANV_SEMAPHORE_TYPE_BO
,
2287 ANV_SEMAPHORE_TYPE_SYNC_FILE
,
2288 ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ
,
2291 struct anv_semaphore_impl
{
2292 enum anv_semaphore_type type
;
2295 /* A BO representing this semaphore when type == ANV_SEMAPHORE_TYPE_BO.
2296 * This BO will be added to the object list on any execbuf2 calls for
2297 * which this semaphore is used as a wait or signal fence. When used as
2298 * a signal fence, the EXEC_OBJECT_WRITE flag will be set.
2302 /* The sync file descriptor when type == ANV_SEMAPHORE_TYPE_SYNC_FILE.
2303 * If the semaphore is in the unsignaled state due to either just being
2304 * created or because it has been used for a wait, fd will be -1.
2308 /* Sync object handle when type == ANV_SEMAPHORE_TYPE_DRM_SYNCOBJ.
2309 * Unlike GEM BOs, DRM sync objects aren't deduplicated by the kernel on
2310 * import so we don't need to bother with a userspace cache.
2316 struct anv_semaphore
{
2317 /* Permanent semaphore state. Every semaphore has some form of permanent
2318 * state (type != ANV_SEMAPHORE_TYPE_NONE). This may be a BO to fence on
2319 * (for cross-process semaphores0 or it could just be a dummy for use
2322 struct anv_semaphore_impl permanent
;
2324 /* Temporary semaphore state. A semaphore *may* have temporary state.
2325 * That state is added to the semaphore by an import operation and is reset
2326 * back to ANV_SEMAPHORE_TYPE_NONE when the semaphore is waited on. A
2327 * semaphore with temporary state cannot be signaled because the semaphore
2328 * must already be signaled before the temporary state can be exported from
2329 * the semaphore in the other process and imported here.
2331 struct anv_semaphore_impl temporary
;
2334 void anv_semaphore_reset_temporary(struct anv_device
*device
,
2335 struct anv_semaphore
*semaphore
);
2337 struct anv_shader_module
{
2338 unsigned char sha1
[20];
2343 static inline gl_shader_stage
2344 vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage
)
2346 assert(__builtin_popcount(vk_stage
) == 1);
2347 return ffs(vk_stage
) - 1;
2350 static inline VkShaderStageFlagBits
2351 mesa_to_vk_shader_stage(gl_shader_stage mesa_stage
)
2353 return (1 << mesa_stage
);
2356 #define ANV_STAGE_MASK ((1 << MESA_SHADER_STAGES) - 1)
2358 #define anv_foreach_stage(stage, stage_bits) \
2359 for (gl_shader_stage stage, \
2360 __tmp = (gl_shader_stage)((stage_bits) & ANV_STAGE_MASK); \
2361 stage = __builtin_ffs(__tmp) - 1, __tmp; \
2362 __tmp &= ~(1 << (stage)))
2364 struct anv_pipeline_bind_map
{
2365 uint32_t surface_count
;
2366 uint32_t sampler_count
;
2367 uint32_t image_count
;
2369 struct anv_pipeline_binding
* surface_to_descriptor
;
2370 struct anv_pipeline_binding
* sampler_to_descriptor
;
2373 struct anv_shader_bin_key
{
2378 struct anv_shader_bin
{
2381 const struct anv_shader_bin_key
*key
;
2383 struct anv_state kernel
;
2384 uint32_t kernel_size
;
2386 struct anv_state constant_data
;
2387 uint32_t constant_data_size
;
2389 const struct brw_stage_prog_data
*prog_data
;
2390 uint32_t prog_data_size
;
2392 struct anv_pipeline_bind_map bind_map
;
2395 struct anv_shader_bin
*
2396 anv_shader_bin_create(struct anv_device
*device
,
2397 const void *key
, uint32_t key_size
,
2398 const void *kernel
, uint32_t kernel_size
,
2399 const void *constant_data
, uint32_t constant_data_size
,
2400 const struct brw_stage_prog_data
*prog_data
,
2401 uint32_t prog_data_size
, const void *prog_data_param
,
2402 const struct anv_pipeline_bind_map
*bind_map
);
2405 anv_shader_bin_destroy(struct anv_device
*device
, struct anv_shader_bin
*shader
);
2408 anv_shader_bin_ref(struct anv_shader_bin
*shader
)
2410 assert(shader
&& shader
->ref_cnt
>= 1);
2411 p_atomic_inc(&shader
->ref_cnt
);
2415 anv_shader_bin_unref(struct anv_device
*device
, struct anv_shader_bin
*shader
)
2417 assert(shader
&& shader
->ref_cnt
>= 1);
2418 if (p_atomic_dec_zero(&shader
->ref_cnt
))
2419 anv_shader_bin_destroy(device
, shader
);
2422 struct anv_pipeline
{
2423 struct anv_device
* device
;
2424 struct anv_batch batch
;
2425 uint32_t batch_data
[512];
2426 struct anv_reloc_list batch_relocs
;
2427 uint32_t dynamic_state_mask
;
2428 struct anv_dynamic_state dynamic_state
;
2430 struct anv_subpass
* subpass
;
2432 bool needs_data_cache
;
2434 struct anv_shader_bin
* shaders
[MESA_SHADER_STAGES
];
2437 const struct gen_l3_config
* l3_config
;
2438 uint32_t total_size
;
2441 VkShaderStageFlags active_stages
;
2442 struct anv_state blend_state
;
2445 struct anv_pipeline_vertex_binding
{
2448 uint32_t instance_divisor
;
2451 bool primitive_restart
;
2454 uint32_t cs_right_mask
;
2457 bool depth_test_enable
;
2458 bool writes_stencil
;
2459 bool stencil_test_enable
;
2460 bool depth_clamp_enable
;
2461 bool sample_shading_enable
;
2466 uint32_t depth_stencil_state
[3];
2472 uint32_t wm_depth_stencil
[3];
2476 uint32_t wm_depth_stencil
[4];
2479 uint32_t interface_descriptor_data
[8];
2483 anv_pipeline_has_stage(const struct anv_pipeline
*pipeline
,
2484 gl_shader_stage stage
)
2486 return (pipeline
->active_stages
& mesa_to_vk_shader_stage(stage
)) != 0;
2489 #define ANV_DECL_GET_PROG_DATA_FUNC(prefix, stage) \
2490 static inline const struct brw_##prefix##_prog_data * \
2491 get_##prefix##_prog_data(const struct anv_pipeline *pipeline) \
2493 if (anv_pipeline_has_stage(pipeline, stage)) { \
2494 return (const struct brw_##prefix##_prog_data *) \
2495 pipeline->shaders[stage]->prog_data; \
2501 ANV_DECL_GET_PROG_DATA_FUNC(vs
, MESA_SHADER_VERTEX
)
2502 ANV_DECL_GET_PROG_DATA_FUNC(tcs
, MESA_SHADER_TESS_CTRL
)
2503 ANV_DECL_GET_PROG_DATA_FUNC(tes
, MESA_SHADER_TESS_EVAL
)
2504 ANV_DECL_GET_PROG_DATA_FUNC(gs
, MESA_SHADER_GEOMETRY
)
2505 ANV_DECL_GET_PROG_DATA_FUNC(wm
, MESA_SHADER_FRAGMENT
)
2506 ANV_DECL_GET_PROG_DATA_FUNC(cs
, MESA_SHADER_COMPUTE
)
2508 static inline const struct brw_vue_prog_data
*
2509 anv_pipeline_get_last_vue_prog_data(const struct anv_pipeline
*pipeline
)
2511 if (anv_pipeline_has_stage(pipeline
, MESA_SHADER_GEOMETRY
))
2512 return &get_gs_prog_data(pipeline
)->base
;
2513 else if (anv_pipeline_has_stage(pipeline
, MESA_SHADER_TESS_EVAL
))
2514 return &get_tes_prog_data(pipeline
)->base
;
2516 return &get_vs_prog_data(pipeline
)->base
;
2520 anv_pipeline_init(struct anv_pipeline
*pipeline
, struct anv_device
*device
,
2521 struct anv_pipeline_cache
*cache
,
2522 const VkGraphicsPipelineCreateInfo
*pCreateInfo
,
2523 const VkAllocationCallbacks
*alloc
);
2526 anv_pipeline_compile_cs(struct anv_pipeline
*pipeline
,
2527 struct anv_pipeline_cache
*cache
,
2528 const VkComputePipelineCreateInfo
*info
,
2529 const struct anv_shader_module
*module
,
2530 const char *entrypoint
,
2531 const VkSpecializationInfo
*spec_info
);
2533 struct anv_format_plane
{
2534 enum isl_format isl_format
:16;
2535 struct isl_swizzle swizzle
;
2537 /* Whether this plane contains chroma channels */
2540 /* For downscaling of YUV planes */
2541 uint8_t denominator_scales
[2];
2543 /* How to map sampled ycbcr planes to a single 4 component element. */
2544 struct isl_swizzle ycbcr_swizzle
;
2546 /* What aspect is associated to this plane */
2547 VkImageAspectFlags aspect
;
2552 struct anv_format_plane planes
[3];
2557 static inline uint32_t
2558 anv_image_aspect_to_plane(VkImageAspectFlags image_aspects
,
2559 VkImageAspectFlags aspect_mask
)
2561 switch (aspect_mask
) {
2562 case VK_IMAGE_ASPECT_COLOR_BIT
:
2563 case VK_IMAGE_ASPECT_DEPTH_BIT
:
2564 case VK_IMAGE_ASPECT_PLANE_0_BIT
:
2566 case VK_IMAGE_ASPECT_STENCIL_BIT
:
2567 if ((image_aspects
& VK_IMAGE_ASPECT_DEPTH_BIT
) == 0)
2570 case VK_IMAGE_ASPECT_PLANE_1_BIT
:
2572 case VK_IMAGE_ASPECT_PLANE_2_BIT
:
2575 /* Purposefully assert with depth/stencil aspects. */
2576 unreachable("invalid image aspect");
2580 static inline VkImageAspectFlags
2581 anv_plane_to_aspect(VkImageAspectFlags image_aspects
,
2584 if (image_aspects
& VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV
) {
2585 if (util_bitcount(image_aspects
) > 1)
2586 return VK_IMAGE_ASPECT_PLANE_0_BIT
<< plane
;
2587 return VK_IMAGE_ASPECT_COLOR_BIT
;
2589 if (image_aspects
& VK_IMAGE_ASPECT_DEPTH_BIT
)
2590 return VK_IMAGE_ASPECT_DEPTH_BIT
<< plane
;
2591 assert(image_aspects
== VK_IMAGE_ASPECT_STENCIL_BIT
);
2592 return VK_IMAGE_ASPECT_STENCIL_BIT
;
2595 #define anv_foreach_image_aspect_bit(b, image, aspects) \
2596 for_each_bit(b, anv_image_expand_aspects(image, aspects))
2598 const struct anv_format
*
2599 anv_get_format(VkFormat format
);
2601 static inline uint32_t
2602 anv_get_format_planes(VkFormat vk_format
)
2604 const struct anv_format
*format
= anv_get_format(vk_format
);
2606 return format
!= NULL
? format
->n_planes
: 0;
2609 struct anv_format_plane
2610 anv_get_format_plane(const struct gen_device_info
*devinfo
, VkFormat vk_format
,
2611 VkImageAspectFlagBits aspect
, VkImageTiling tiling
);
2613 static inline enum isl_format
2614 anv_get_isl_format(const struct gen_device_info
*devinfo
, VkFormat vk_format
,
2615 VkImageAspectFlags aspect
, VkImageTiling tiling
)
2617 return anv_get_format_plane(devinfo
, vk_format
, aspect
, tiling
).isl_format
;
2620 static inline struct isl_swizzle
2621 anv_swizzle_for_render(struct isl_swizzle swizzle
)
2623 /* Sometimes the swizzle will have alpha map to one. We do this to fake
2624 * RGB as RGBA for texturing
2626 assert(swizzle
.a
== ISL_CHANNEL_SELECT_ONE
||
2627 swizzle
.a
== ISL_CHANNEL_SELECT_ALPHA
);
2629 /* But it doesn't matter what we render to that channel */
2630 swizzle
.a
= ISL_CHANNEL_SELECT_ALPHA
;
2636 anv_pipeline_setup_l3_config(struct anv_pipeline
*pipeline
, bool needs_slm
);
2639 * Subsurface of an anv_image.
2641 struct anv_surface
{
2642 /** Valid only if isl_surf::size_B > 0. */
2643 struct isl_surf isl
;
2646 * Offset from VkImage's base address, as bound by vkBindImageMemory().
2653 /* The original VkFormat provided by the client. This may not match any
2654 * of the actual surface formats.
2657 const struct anv_format
*format
;
2659 VkImageAspectFlags aspects
;
2662 uint32_t array_size
;
2663 uint32_t samples
; /**< VkImageCreateInfo::samples */
2665 VkImageUsageFlags usage
; /**< Superset of VkImageCreateInfo::usage. */
2666 VkImageCreateFlags create_flags
; /* Flags used when creating image. */
2667 VkImageTiling tiling
; /** VkImageCreateInfo::tiling */
2669 /** True if this is needs to be bound to an appropriately tiled BO.
2671 * When not using modifiers, consumers such as X11, Wayland, and KMS need
2672 * the tiling passed via I915_GEM_SET_TILING. When exporting these buffers
2673 * we require a dedicated allocation so that we can know to allocate a
2676 bool needs_set_tiling
;
2679 * Must be DRM_FORMAT_MOD_INVALID unless tiling is
2680 * VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT.
2682 uint64_t drm_format_mod
;
2687 /* Whether the image is made of several underlying buffer objects rather a
2688 * single one with different offsets.
2692 /* All the formats that can be used when creating views of this image
2693 * are CCS_E compatible.
2695 bool ccs_e_compatible
;
2700 * For each foo, anv_image::planes[x].surface is valid if and only if
2701 * anv_image::aspects has a x aspect. Refer to anv_image_aspect_to_plane()
2702 * to figure the number associated with a given aspect.
2704 * The hardware requires that the depth buffer and stencil buffer be
2705 * separate surfaces. From Vulkan's perspective, though, depth and stencil
2706 * reside in the same VkImage. To satisfy both the hardware and Vulkan, we
2707 * allocate the depth and stencil buffers as separate surfaces in the same
2712 * -----------------------
2714 * ----------------------- |
2715 * | shadow surface0 | |
2716 * ----------------------- | Plane 0
2717 * | aux surface0 | |
2718 * ----------------------- |
2719 * | fast clear colors0 | \|/
2720 * -----------------------
2722 * ----------------------- |
2723 * | shadow surface1 | |
2724 * ----------------------- | Plane 1
2725 * | aux surface1 | |
2726 * ----------------------- |
2727 * | fast clear colors1 | \|/
2728 * -----------------------
2731 * -----------------------
2735 * Offset of the entire plane (whenever the image is disjoint this is
2743 struct anv_surface surface
;
2746 * A surface which shadows the main surface and may have different
2747 * tiling. This is used for sampling using a tiling that isn't supported
2748 * for other operations.
2750 struct anv_surface shadow_surface
;
2753 * For color images, this is the aux usage for this image when not used
2754 * as a color attachment.
2756 * For depth/stencil images, this is set to ISL_AUX_USAGE_HIZ if the
2757 * image has a HiZ buffer.
2759 enum isl_aux_usage aux_usage
;
2761 struct anv_surface aux_surface
;
2764 * Offset of the fast clear state (used to compute the
2765 * fast_clear_state_offset of the following planes).
2767 uint32_t fast_clear_state_offset
;
2770 * BO associated with this plane, set when bound.
2772 struct anv_address address
;
2775 * When destroying the image, also free the bo.
2781 /* The ordering of this enum is important */
2782 enum anv_fast_clear_type
{
2783 /** Image does not have/support any fast-clear blocks */
2784 ANV_FAST_CLEAR_NONE
= 0,
2785 /** Image has/supports fast-clear but only to the default value */
2786 ANV_FAST_CLEAR_DEFAULT_VALUE
= 1,
2787 /** Image has/supports fast-clear with an arbitrary fast-clear value */
2788 ANV_FAST_CLEAR_ANY
= 2,
2791 /* Returns the number of auxiliary buffer levels attached to an image. */
2792 static inline uint8_t
2793 anv_image_aux_levels(const struct anv_image
* const image
,
2794 VkImageAspectFlagBits aspect
)
2796 uint32_t plane
= anv_image_aspect_to_plane(image
->aspects
, aspect
);
2797 return image
->planes
[plane
].aux_surface
.isl
.size_B
> 0 ?
2798 image
->planes
[plane
].aux_surface
.isl
.levels
: 0;
2801 /* Returns the number of auxiliary buffer layers attached to an image. */
2802 static inline uint32_t
2803 anv_image_aux_layers(const struct anv_image
* const image
,
2804 VkImageAspectFlagBits aspect
,
2805 const uint8_t miplevel
)
2809 /* The miplevel must exist in the main buffer. */
2810 assert(miplevel
< image
->levels
);
2812 if (miplevel
>= anv_image_aux_levels(image
, aspect
)) {
2813 /* There are no layers with auxiliary data because the miplevel has no
2818 uint32_t plane
= anv_image_aspect_to_plane(image
->aspects
, aspect
);
2819 return MAX2(image
->planes
[plane
].aux_surface
.isl
.logical_level0_px
.array_len
,
2820 image
->planes
[plane
].aux_surface
.isl
.logical_level0_px
.depth
>> miplevel
);
2824 static inline struct anv_address
2825 anv_image_get_clear_color_addr(const struct anv_device
*device
,
2826 const struct anv_image
*image
,
2827 VkImageAspectFlagBits aspect
)
2829 assert(image
->aspects
& VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV
);
2831 uint32_t plane
= anv_image_aspect_to_plane(image
->aspects
, aspect
);
2832 return anv_address_add(image
->planes
[plane
].address
,
2833 image
->planes
[plane
].fast_clear_state_offset
);
2836 static inline struct anv_address
2837 anv_image_get_fast_clear_type_addr(const struct anv_device
*device
,
2838 const struct anv_image
*image
,
2839 VkImageAspectFlagBits aspect
)
2841 struct anv_address addr
=
2842 anv_image_get_clear_color_addr(device
, image
, aspect
);
2844 const unsigned clear_color_state_size
= device
->info
.gen
>= 10 ?
2845 device
->isl_dev
.ss
.clear_color_state_size
:
2846 device
->isl_dev
.ss
.clear_value_size
;
2847 return anv_address_add(addr
, clear_color_state_size
);
2850 static inline struct anv_address
2851 anv_image_get_compression_state_addr(const struct anv_device
*device
,
2852 const struct anv_image
*image
,
2853 VkImageAspectFlagBits aspect
,
2854 uint32_t level
, uint32_t array_layer
)
2856 assert(level
< anv_image_aux_levels(image
, aspect
));
2857 assert(array_layer
< anv_image_aux_layers(image
, aspect
, level
));
2858 UNUSED
uint32_t plane
= anv_image_aspect_to_plane(image
->aspects
, aspect
);
2859 assert(image
->planes
[plane
].aux_usage
== ISL_AUX_USAGE_CCS_E
);
2861 struct anv_address addr
=
2862 anv_image_get_fast_clear_type_addr(device
, image
, aspect
);
2863 addr
.offset
+= 4; /* Go past the fast clear type */
2865 if (image
->type
== VK_IMAGE_TYPE_3D
) {
2866 for (uint32_t l
= 0; l
< level
; l
++)
2867 addr
.offset
+= anv_minify(image
->extent
.depth
, l
) * 4;
2869 addr
.offset
+= level
* image
->array_size
* 4;
2871 addr
.offset
+= array_layer
* 4;
2876 /* Returns true if a HiZ-enabled depth buffer can be sampled from. */
2878 anv_can_sample_with_hiz(const struct gen_device_info
* const devinfo
,
2879 const struct anv_image
*image
)
2881 if (!(image
->aspects
& VK_IMAGE_ASPECT_DEPTH_BIT
))
2884 if (devinfo
->gen
< 8)
2887 return image
->samples
== 1;
2891 anv_cmd_buffer_mark_image_written(struct anv_cmd_buffer
*cmd_buffer
,
2892 const struct anv_image
*image
,
2893 VkImageAspectFlagBits aspect
,
2894 enum isl_aux_usage aux_usage
,
2896 uint32_t base_layer
,
2897 uint32_t layer_count
);
2900 anv_image_clear_color(struct anv_cmd_buffer
*cmd_buffer
,
2901 const struct anv_image
*image
,
2902 VkImageAspectFlagBits aspect
,
2903 enum isl_aux_usage aux_usage
,
2904 enum isl_format format
, struct isl_swizzle swizzle
,
2905 uint32_t level
, uint32_t base_layer
, uint32_t layer_count
,
2906 VkRect2D area
, union isl_color_value clear_color
);
2908 anv_image_clear_depth_stencil(struct anv_cmd_buffer
*cmd_buffer
,
2909 const struct anv_image
*image
,
2910 VkImageAspectFlags aspects
,
2911 enum isl_aux_usage depth_aux_usage
,
2913 uint32_t base_layer
, uint32_t layer_count
,
2915 float depth_value
, uint8_t stencil_value
);
2917 anv_image_hiz_op(struct anv_cmd_buffer
*cmd_buffer
,
2918 const struct anv_image
*image
,
2919 VkImageAspectFlagBits aspect
, uint32_t level
,
2920 uint32_t base_layer
, uint32_t layer_count
,
2921 enum isl_aux_op hiz_op
);
2923 anv_image_hiz_clear(struct anv_cmd_buffer
*cmd_buffer
,
2924 const struct anv_image
*image
,
2925 VkImageAspectFlags aspects
,
2927 uint32_t base_layer
, uint32_t layer_count
,
2928 VkRect2D area
, uint8_t stencil_value
);
2930 anv_image_mcs_op(struct anv_cmd_buffer
*cmd_buffer
,
2931 const struct anv_image
*image
,
2932 VkImageAspectFlagBits aspect
,
2933 uint32_t base_layer
, uint32_t layer_count
,
2934 enum isl_aux_op mcs_op
, union isl_color_value
*clear_value
,
2937 anv_image_ccs_op(struct anv_cmd_buffer
*cmd_buffer
,
2938 const struct anv_image
*image
,
2939 VkImageAspectFlagBits aspect
, uint32_t level
,
2940 uint32_t base_layer
, uint32_t layer_count
,
2941 enum isl_aux_op ccs_op
, union isl_color_value
*clear_value
,
2945 anv_image_copy_to_shadow(struct anv_cmd_buffer
*cmd_buffer
,
2946 const struct anv_image
*image
,
2947 uint32_t base_level
, uint32_t level_count
,
2948 uint32_t base_layer
, uint32_t layer_count
);
2951 anv_layout_to_aux_usage(const struct gen_device_info
* const devinfo
,
2952 const struct anv_image
*image
,
2953 const VkImageAspectFlagBits aspect
,
2954 const VkImageLayout layout
);
2956 enum anv_fast_clear_type
2957 anv_layout_to_fast_clear_type(const struct gen_device_info
* const devinfo
,
2958 const struct anv_image
* const image
,
2959 const VkImageAspectFlagBits aspect
,
2960 const VkImageLayout layout
);
2962 /* This is defined as a macro so that it works for both
2963 * VkImageSubresourceRange and VkImageSubresourceLayers
2965 #define anv_get_layerCount(_image, _range) \
2966 ((_range)->layerCount == VK_REMAINING_ARRAY_LAYERS ? \
2967 (_image)->array_size - (_range)->baseArrayLayer : (_range)->layerCount)
2969 static inline uint32_t
2970 anv_get_levelCount(const struct anv_image
*image
,
2971 const VkImageSubresourceRange
*range
)
2973 return range
->levelCount
== VK_REMAINING_MIP_LEVELS
?
2974 image
->levels
- range
->baseMipLevel
: range
->levelCount
;
2977 static inline VkImageAspectFlags
2978 anv_image_expand_aspects(const struct anv_image
*image
,
2979 VkImageAspectFlags aspects
)
2981 /* If the underlying image has color plane aspects and
2982 * VK_IMAGE_ASPECT_COLOR_BIT has been requested, then return the aspects of
2983 * the underlying image. */
2984 if ((image
->aspects
& VK_IMAGE_ASPECT_PLANES_BITS_ANV
) != 0 &&
2985 aspects
== VK_IMAGE_ASPECT_COLOR_BIT
)
2986 return image
->aspects
;
2992 anv_image_aspects_compatible(VkImageAspectFlags aspects1
,
2993 VkImageAspectFlags aspects2
)
2995 if (aspects1
== aspects2
)
2998 /* Only 1 color aspects are compatibles. */
2999 if ((aspects1
& VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV
) != 0 &&
3000 (aspects2
& VK_IMAGE_ASPECT_ANY_COLOR_BIT_ANV
) != 0 &&
3001 util_bitcount(aspects1
) == util_bitcount(aspects2
))
3007 struct anv_image_view
{
3008 const struct anv_image
*image
; /**< VkImageViewCreateInfo::image */
3010 VkImageAspectFlags aspect_mask
;
3012 VkExtent3D extent
; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */
3016 uint32_t image_plane
;
3018 struct isl_view isl
;
3021 * RENDER_SURFACE_STATE when using image as a sampler surface with an
3022 * image layout of SHADER_READ_ONLY_OPTIMAL or
3023 * DEPTH_STENCIL_READ_ONLY_OPTIMAL.
3025 struct anv_surface_state optimal_sampler_surface_state
;
3028 * RENDER_SURFACE_STATE when using image as a sampler surface with an
3029 * image layout of GENERAL.
3031 struct anv_surface_state general_sampler_surface_state
;
3034 * RENDER_SURFACE_STATE when using image as a storage image. Separate
3035 * states for write-only and readable, using the real format for
3036 * write-only and the lowered format for readable.
3038 struct anv_surface_state storage_surface_state
;
3039 struct anv_surface_state writeonly_storage_surface_state
;
3041 struct brw_image_param storage_image_param
;
3045 enum anv_image_view_state_flags
{
3046 ANV_IMAGE_VIEW_STATE_STORAGE_WRITE_ONLY
= (1 << 0),
3047 ANV_IMAGE_VIEW_STATE_TEXTURE_OPTIMAL
= (1 << 1),
3050 void anv_image_fill_surface_state(struct anv_device
*device
,
3051 const struct anv_image
*image
,
3052 VkImageAspectFlagBits aspect
,
3053 const struct isl_view
*view
,
3054 isl_surf_usage_flags_t view_usage
,
3055 enum isl_aux_usage aux_usage
,
3056 const union isl_color_value
*clear_color
,
3057 enum anv_image_view_state_flags flags
,
3058 struct anv_surface_state
*state_inout
,
3059 struct brw_image_param
*image_param_out
);
3061 struct anv_image_create_info
{
3062 const VkImageCreateInfo
*vk_info
;
3064 /** An opt-in bitmask which filters an ISL-mapping of the Vulkan tiling. */
3065 isl_tiling_flags_t isl_tiling_flags
;
3067 /** These flags will be added to any derived from VkImageCreateInfo. */
3068 isl_surf_usage_flags_t isl_extra_usage_flags
;
3073 VkResult
anv_image_create(VkDevice _device
,
3074 const struct anv_image_create_info
*info
,
3075 const VkAllocationCallbacks
* alloc
,
3078 const struct anv_surface
*
3079 anv_image_get_surface_for_aspect_mask(const struct anv_image
*image
,
3080 VkImageAspectFlags aspect_mask
);
3083 anv_isl_format_for_descriptor_type(VkDescriptorType type
);
3085 static inline struct VkExtent3D
3086 anv_sanitize_image_extent(const VkImageType imageType
,
3087 const struct VkExtent3D imageExtent
)
3089 switch (imageType
) {
3090 case VK_IMAGE_TYPE_1D
:
3091 return (VkExtent3D
) { imageExtent
.width
, 1, 1 };
3092 case VK_IMAGE_TYPE_2D
:
3093 return (VkExtent3D
) { imageExtent
.width
, imageExtent
.height
, 1 };
3094 case VK_IMAGE_TYPE_3D
:
3097 unreachable("invalid image type");
3101 static inline struct VkOffset3D
3102 anv_sanitize_image_offset(const VkImageType imageType
,
3103 const struct VkOffset3D imageOffset
)
3105 switch (imageType
) {
3106 case VK_IMAGE_TYPE_1D
:
3107 return (VkOffset3D
) { imageOffset
.x
, 0, 0 };
3108 case VK_IMAGE_TYPE_2D
:
3109 return (VkOffset3D
) { imageOffset
.x
, imageOffset
.y
, 0 };
3110 case VK_IMAGE_TYPE_3D
:
3113 unreachable("invalid image type");
3117 VkFormatFeatureFlags
3118 anv_get_image_format_features(const struct gen_device_info
*devinfo
,
3120 const struct anv_format
*anv_format
,
3121 VkImageTiling vk_tiling
);
3123 void anv_fill_buffer_surface_state(struct anv_device
*device
,
3124 struct anv_state state
,
3125 enum isl_format format
,
3126 struct anv_address address
,
3127 uint32_t range
, uint32_t stride
);
3130 anv_clear_color_from_att_state(union isl_color_value
*clear_color
,
3131 const struct anv_attachment_state
*att_state
,
3132 const struct anv_image_view
*iview
)
3134 const struct isl_format_layout
*view_fmtl
=
3135 isl_format_get_layout(iview
->planes
[0].isl
.format
);
3137 #define COPY_CLEAR_COLOR_CHANNEL(c, i) \
3138 if (view_fmtl->channels.c.bits) \
3139 clear_color->u32[i] = att_state->clear_value.color.uint32[i]
3141 COPY_CLEAR_COLOR_CHANNEL(r
, 0);
3142 COPY_CLEAR_COLOR_CHANNEL(g
, 1);
3143 COPY_CLEAR_COLOR_CHANNEL(b
, 2);
3144 COPY_CLEAR_COLOR_CHANNEL(a
, 3);
3146 #undef COPY_CLEAR_COLOR_CHANNEL
3150 struct anv_ycbcr_conversion
{
3151 const struct anv_format
* format
;
3152 VkSamplerYcbcrModelConversion ycbcr_model
;
3153 VkSamplerYcbcrRange ycbcr_range
;
3154 VkComponentSwizzle mapping
[4];
3155 VkChromaLocation chroma_offsets
[2];
3156 VkFilter chroma_filter
;
3157 bool chroma_reconstruction
;
3160 struct anv_sampler
{
3161 uint32_t state
[3][4];
3163 struct anv_ycbcr_conversion
*conversion
;
3166 struct anv_framebuffer
{
3171 uint32_t attachment_count
;
3172 struct anv_image_view
* attachments
[0];
3175 struct anv_subpass_attachment
{
3176 VkImageUsageFlagBits usage
;
3177 uint32_t attachment
;
3178 VkImageLayout layout
;
3181 struct anv_subpass
{
3182 uint32_t attachment_count
;
3185 * A pointer to all attachment references used in this subpass.
3186 * Only valid if ::attachment_count > 0.
3188 struct anv_subpass_attachment
* attachments
;
3189 uint32_t input_count
;
3190 struct anv_subpass_attachment
* input_attachments
;
3191 uint32_t color_count
;
3192 struct anv_subpass_attachment
* color_attachments
;
3193 struct anv_subpass_attachment
* resolve_attachments
;
3195 struct anv_subpass_attachment
* depth_stencil_attachment
;
3199 /** Subpass has a depth/stencil self-dependency */
3200 bool has_ds_self_dep
;
3202 /** Subpass has at least one resolve attachment */
3206 static inline unsigned
3207 anv_subpass_view_count(const struct anv_subpass
*subpass
)
3209 return MAX2(1, util_bitcount(subpass
->view_mask
));
3212 struct anv_render_pass_attachment
{
3213 /* TODO: Consider using VkAttachmentDescription instead of storing each of
3214 * its members individually.
3218 VkImageUsageFlags usage
;
3219 VkAttachmentLoadOp load_op
;
3220 VkAttachmentStoreOp store_op
;
3221 VkAttachmentLoadOp stencil_load_op
;
3222 VkImageLayout initial_layout
;
3223 VkImageLayout final_layout
;
3224 VkImageLayout first_subpass_layout
;
3226 /* The subpass id in which the attachment will be used last. */
3227 uint32_t last_subpass_idx
;
3230 struct anv_render_pass
{
3231 uint32_t attachment_count
;
3232 uint32_t subpass_count
;
3233 /* An array of subpass_count+1 flushes, one per subpass boundary */
3234 enum anv_pipe_bits
* subpass_flushes
;
3235 struct anv_render_pass_attachment
* attachments
;
3236 struct anv_subpass subpasses
[0];
3239 #define ANV_PIPELINE_STATISTICS_MASK 0x000007ff
3241 struct anv_query_pool
{
3243 VkQueryPipelineStatisticFlags pipeline_statistics
;
3244 /** Stride between slots, in bytes */
3246 /** Number of slots in this query pool */
3251 int anv_get_instance_entrypoint_index(const char *name
);
3252 int anv_get_device_entrypoint_index(const char *name
);
3255 anv_instance_entrypoint_is_enabled(int index
, uint32_t core_version
,
3256 const struct anv_instance_extension_table
*instance
);
3259 anv_device_entrypoint_is_enabled(int index
, uint32_t core_version
,
3260 const struct anv_instance_extension_table
*instance
,
3261 const struct anv_device_extension_table
*device
);
3263 void *anv_lookup_entrypoint(const struct gen_device_info
*devinfo
,
3266 void anv_dump_image_to_ppm(struct anv_device
*device
,
3267 struct anv_image
*image
, unsigned miplevel
,
3268 unsigned array_layer
, VkImageAspectFlagBits aspect
,
3269 const char *filename
);
3271 enum anv_dump_action
{
3272 ANV_DUMP_FRAMEBUFFERS_BIT
= 0x1,
3275 void anv_dump_start(struct anv_device
*device
, enum anv_dump_action actions
);
3276 void anv_dump_finish(void);
3278 void anv_dump_add_framebuffer(struct anv_cmd_buffer
*cmd_buffer
,
3279 struct anv_framebuffer
*fb
);
3281 static inline uint32_t
3282 anv_get_subpass_id(const struct anv_cmd_state
* const cmd_state
)
3284 /* This function must be called from within a subpass. */
3285 assert(cmd_state
->pass
&& cmd_state
->subpass
);
3287 const uint32_t subpass_id
= cmd_state
->subpass
- cmd_state
->pass
->subpasses
;
3289 /* The id of this subpass shouldn't exceed the number of subpasses in this
3290 * render pass minus 1.
3292 assert(subpass_id
< cmd_state
->pass
->subpass_count
);
3296 #define ANV_DEFINE_HANDLE_CASTS(__anv_type, __VkType) \
3298 static inline struct __anv_type * \
3299 __anv_type ## _from_handle(__VkType _handle) \
3301 return (struct __anv_type *) _handle; \
3304 static inline __VkType \
3305 __anv_type ## _to_handle(struct __anv_type *_obj) \
3307 return (__VkType) _obj; \
3310 #define ANV_DEFINE_NONDISP_HANDLE_CASTS(__anv_type, __VkType) \
3312 static inline struct __anv_type * \
3313 __anv_type ## _from_handle(__VkType _handle) \
3315 return (struct __anv_type *)(uintptr_t) _handle; \
3318 static inline __VkType \
3319 __anv_type ## _to_handle(struct __anv_type *_obj) \
3321 return (__VkType)(uintptr_t) _obj; \
3324 #define ANV_FROM_HANDLE(__anv_type, __name, __handle) \
3325 struct __anv_type *__name = __anv_type ## _from_handle(__handle)
3327 ANV_DEFINE_HANDLE_CASTS(anv_cmd_buffer
, VkCommandBuffer
)
3328 ANV_DEFINE_HANDLE_CASTS(anv_device
, VkDevice
)
3329 ANV_DEFINE_HANDLE_CASTS(anv_instance
, VkInstance
)
3330 ANV_DEFINE_HANDLE_CASTS(anv_physical_device
, VkPhysicalDevice
)
3331 ANV_DEFINE_HANDLE_CASTS(anv_queue
, VkQueue
)
3333 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_cmd_pool
, VkCommandPool
)
3334 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer
, VkBuffer
)
3335 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer_view
, VkBufferView
)
3336 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_pool
, VkDescriptorPool
)
3337 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set
, VkDescriptorSet
)
3338 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set_layout
, VkDescriptorSetLayout
)
3339 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_update_template
, VkDescriptorUpdateTemplateKHR
)
3340 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_device_memory
, VkDeviceMemory
)
3341 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_fence
, VkFence
)
3342 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_event
, VkEvent
)
3343 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_framebuffer
, VkFramebuffer
)
3344 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_image
, VkImage
)
3345 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_image_view
, VkImageView
);
3346 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline_cache
, VkPipelineCache
)
3347 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline
, VkPipeline
)
3348 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_pipeline_layout
, VkPipelineLayout
)
3349 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_query_pool
, VkQueryPool
)
3350 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_render_pass
, VkRenderPass
)
3351 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_sampler
, VkSampler
)
3352 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_semaphore
, VkSemaphore
)
3353 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_shader_module
, VkShaderModule
)
3354 ANV_DEFINE_NONDISP_HANDLE_CASTS(vk_debug_report_callback
, VkDebugReportCallbackEXT
)
3355 ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_ycbcr_conversion
, VkSamplerYcbcrConversion
)
3357 /* Gen-specific function declarations */
3359 # include "anv_genX.h"
3361 # define genX(x) gen7_##x
3362 # include "anv_genX.h"
3364 # define genX(x) gen75_##x
3365 # include "anv_genX.h"
3367 # define genX(x) gen8_##x
3368 # include "anv_genX.h"
3370 # define genX(x) gen9_##x
3371 # include "anv_genX.h"
3373 # define genX(x) gen10_##x
3374 # include "anv_genX.h"
3376 # define genX(x) gen11_##x
3377 # include "anv_genX.h"
3381 #endif /* ANV_PRIVATE_H */