1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2016 Red Hat. 3bf215546Sopenharmony_ci * Copyright © 2016 Bas Nieuwenhuizen 4bf215546Sopenharmony_ci * SPDX-License-Identifier: MIT 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * based in part on anv driver which is: 7bf215546Sopenharmony_ci * Copyright © 2015 Intel Corporation 8bf215546Sopenharmony_ci */ 9bf215546Sopenharmony_ci 10bf215546Sopenharmony_ci#ifndef TU_COMMON_H 11bf215546Sopenharmony_ci#define TU_COMMON_H 12bf215546Sopenharmony_ci 13bf215546Sopenharmony_ci#include <assert.h> 14bf215546Sopenharmony_ci#include <pthread.h> 15bf215546Sopenharmony_ci#include <stdbool.h> 16bf215546Sopenharmony_ci#include <stdint.h> 17bf215546Sopenharmony_ci#include <stdio.h> 18bf215546Sopenharmony_ci#include <stdlib.h> 19bf215546Sopenharmony_ci#include <string.h> 20bf215546Sopenharmony_ci#ifdef HAVE_VALGRIND 21bf215546Sopenharmony_ci#include <memcheck.h> 22bf215546Sopenharmony_ci#include <valgrind.h> 23bf215546Sopenharmony_ci#define VG(x) x 24bf215546Sopenharmony_ci#else 25bf215546Sopenharmony_ci#define VG(x) ((void)0) 26bf215546Sopenharmony_ci#endif 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#define MESA_LOG_TAG "TU" 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#include "c11/threads.h" 31bf215546Sopenharmony_ci#include "util/rounding.h" 32bf215546Sopenharmony_ci#include "util/bitscan.h" 33bf215546Sopenharmony_ci#include "util/list.h" 34bf215546Sopenharmony_ci#include "util/log.h" 35bf215546Sopenharmony_ci#include "util/macros.h" 36bf215546Sopenharmony_ci#include "util/sparse_array.h" 37bf215546Sopenharmony_ci#include "util/u_atomic.h" 38bf215546Sopenharmony_ci#include "util/u_dynarray.h" 39bf215546Sopenharmony_ci#include "util/xmlconfig.h" 40bf215546Sopenharmony_ci#include "util/perf/u_trace.h" 41bf215546Sopenharmony_ci#include "vk_alloc.h" 42bf215546Sopenharmony_ci#include "vk_debug_report.h" 43bf215546Sopenharmony_ci#include "vk_device.h" 44bf215546Sopenharmony_ci#include "vk_dispatch_table.h" 45bf215546Sopenharmony_ci#include "vk_extensions.h" 46bf215546Sopenharmony_ci#include "vk_instance.h" 47bf215546Sopenharmony_ci#include "vk_log.h" 48bf215546Sopenharmony_ci#include "vk_physical_device.h" 49bf215546Sopenharmony_ci#include "vk_shader_module.h" 50bf215546Sopenharmony_ci#include "vk_pipeline_cache.h" 51bf215546Sopenharmony_ci#include "wsi_common.h" 52bf215546Sopenharmony_ci 53bf215546Sopenharmony_ci#include "ir3/ir3_compiler.h" 54bf215546Sopenharmony_ci#include "ir3/ir3_shader.h" 55bf215546Sopenharmony_ci 56bf215546Sopenharmony_ci#include "adreno_common.xml.h" 57bf215546Sopenharmony_ci#include "adreno_pm4.xml.h" 58bf215546Sopenharmony_ci#include "a6xx.xml.h" 59bf215546Sopenharmony_ci#include "fdl/freedreno_layout.h" 60bf215546Sopenharmony_ci#include "common/freedreno_dev_info.h" 61bf215546Sopenharmony_ci#include "common/freedreno_common.h" 62bf215546Sopenharmony_ci#include "perfcntrs/freedreno_perfcntr.h" 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci#include <vulkan/vk_android_native_buffer.h> 65bf215546Sopenharmony_ci#include <vulkan/vk_icd.h> 66bf215546Sopenharmony_ci#include <vulkan/vulkan.h> 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_ci#include "tu_entrypoints.h" 69bf215546Sopenharmony_ci#include "vulkan/runtime/vk_common_entrypoints.h" 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci#include "vk_format.h" 72bf215546Sopenharmony_ci#include "vk_image.h" 73bf215546Sopenharmony_ci#include "vk_command_buffer.h" 74bf215546Sopenharmony_ci#include "vk_command_pool.h" 75bf215546Sopenharmony_ci#include "vk_queue.h" 76bf215546Sopenharmony_ci#include "vk_object.h" 77bf215546Sopenharmony_ci#include "vk_sync.h" 78bf215546Sopenharmony_ci#include "vk_drm_syncobj.h" 79bf215546Sopenharmony_ci#include "vk_sync_timeline.h" 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci#define MAX_VBS 32 82bf215546Sopenharmony_ci#define MAX_VERTEX_ATTRIBS 32 83bf215546Sopenharmony_ci#define MAX_RTS 8 84bf215546Sopenharmony_ci#define MAX_VSC_PIPES 32 85bf215546Sopenharmony_ci#define MAX_VIEWPORTS 16 86bf215546Sopenharmony_ci#define MAX_VIEWPORT_SIZE (1 << 14) 87bf215546Sopenharmony_ci#define MAX_SCISSORS 16 88bf215546Sopenharmony_ci#define MAX_DISCARD_RECTANGLES 4 89bf215546Sopenharmony_ci#define MAX_PUSH_CONSTANTS_SIZE 256 90bf215546Sopenharmony_ci#define MAX_PUSH_DESCRIPTORS 32 91bf215546Sopenharmony_ci#define MAX_DYNAMIC_UNIFORM_BUFFERS 16 92bf215546Sopenharmony_ci#define MAX_DYNAMIC_STORAGE_BUFFERS 8 93bf215546Sopenharmony_ci#define MAX_DYNAMIC_BUFFERS_SIZE \ 94bf215546Sopenharmony_ci (MAX_DYNAMIC_UNIFORM_BUFFERS + 2 * MAX_DYNAMIC_STORAGE_BUFFERS) * \ 95bf215546Sopenharmony_ci A6XX_TEX_CONST_DWORDS 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ci#define TU_MAX_DRM_DEVICES 8 98bf215546Sopenharmony_ci#define MAX_VIEWS 16 99bf215546Sopenharmony_ci#define MAX_BIND_POINTS 2 /* compute + graphics */ 100bf215546Sopenharmony_ci/* The Qualcomm driver exposes 0x20000058 */ 101bf215546Sopenharmony_ci#define MAX_STORAGE_BUFFER_RANGE 0x20000000 102bf215546Sopenharmony_ci/* We use ldc for uniform buffer loads, just like the Qualcomm driver, so 103bf215546Sopenharmony_ci * expose the same maximum range. 104bf215546Sopenharmony_ci * TODO: The SIZE bitfield is 15 bits, and in 4-dword units, so the actual 105bf215546Sopenharmony_ci * range might be higher. 106bf215546Sopenharmony_ci */ 107bf215546Sopenharmony_ci#define MAX_UNIFORM_BUFFER_RANGE 0x10000 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci#define A6XX_TEX_CONST_DWORDS 16 110bf215546Sopenharmony_ci#define A6XX_TEX_SAMP_DWORDS 4 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci#define TU_FROM_HANDLE(__tu_type, __name, __handle) \ 113bf215546Sopenharmony_ci VK_FROM_HANDLE(__tu_type, __name, __handle) 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci/* vk object types */ 116bf215546Sopenharmony_cistruct tu_buffer; 117bf215546Sopenharmony_cistruct tu_buffer_view; 118bf215546Sopenharmony_cistruct tu_cmd_buffer; 119bf215546Sopenharmony_cistruct tu_cmd_pool; 120bf215546Sopenharmony_cistruct tu_descriptor_pool; 121bf215546Sopenharmony_cistruct tu_descriptor_set; 122bf215546Sopenharmony_cistruct tu_descriptor_set_layout; 123bf215546Sopenharmony_cistruct tu_descriptor_update_template; 124bf215546Sopenharmony_cistruct tu_device; 125bf215546Sopenharmony_cistruct tu_device_memory; 126bf215546Sopenharmony_cistruct tu_event; 127bf215546Sopenharmony_cistruct tu_framebuffer; 128bf215546Sopenharmony_cistruct tu_image; 129bf215546Sopenharmony_cistruct tu_image_view; 130bf215546Sopenharmony_cistruct tu_instance; 131bf215546Sopenharmony_cistruct tu_physical_device; 132bf215546Sopenharmony_cistruct tu_pipeline_layout; 133bf215546Sopenharmony_cistruct tu_query_pool; 134bf215546Sopenharmony_cistruct tu_queue; 135bf215546Sopenharmony_cistruct tu_render_pass; 136bf215546Sopenharmony_cistruct tu_sampler; 137bf215546Sopenharmony_cistruct tu_sampler_ycbcr_conversion; 138bf215546Sopenharmony_ci 139bf215546Sopenharmony_cistruct breadcrumbs_context; 140bf215546Sopenharmony_cistruct tu_bo; 141bf215546Sopenharmony_cistruct tu_cs; 142bf215546Sopenharmony_cistruct tu_cs_entry; 143bf215546Sopenharmony_cistruct tu_suballoc_bo; 144bf215546Sopenharmony_cistruct tu_suballocator; 145bf215546Sopenharmony_cistruct tu_subpass; 146bf215546Sopenharmony_cistruct tu_u_trace_submission_data; 147bf215546Sopenharmony_ci 148bf215546Sopenharmony_ci#endif /* TU_COMMON_H */ 149