Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2016 Red Hat. |
| 3 | * Copyright © 2016 Bas Nieuwenhuizen |
| 4 | * |
| 5 | * based in part on anv driver which is: |
| 6 | * Copyright © 2015 Intel Corporation |
| 7 | * |
| 8 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 9 | * copy of this software and associated documentation files (the "Software"), |
| 10 | * to deal in the Software without restriction, including without limitation |
| 11 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 12 | * and/or sell copies of the Software, and to permit persons to whom the |
| 13 | * Software is furnished to do so, subject to the following conditions: |
| 14 | * |
| 15 | * The above copyright notice and this permission notice (including the next |
| 16 | * paragraph) shall be included in all copies or substantial portions of the |
| 17 | * Software. |
| 18 | * |
| 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 22 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 24 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 25 | * IN THE SOFTWARE. |
| 26 | */ |
| 27 | |
Edward O'Callaghan | ba43768 | 2016-10-07 22:19:19 +1100 | [diff] [blame] | 28 | #ifndef RADV_PRIVATE_H |
| 29 | #define RADV_PRIVATE_H |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 30 | |
| 31 | #include <stdlib.h> |
| 32 | #include <stdio.h> |
| 33 | #include <stdbool.h> |
| 34 | #include <pthread.h> |
| 35 | #include <assert.h> |
| 36 | #include <stdint.h> |
| 37 | #include <string.h> |
| 38 | #ifdef HAVE_VALGRIND |
| 39 | #include <valgrind.h> |
| 40 | #include <memcheck.h> |
| 41 | #define VG(x) x |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 42 | #else |
| 43 | #define VG(x) |
| 44 | #endif |
| 45 | |
| 46 | #include <amdgpu.h> |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 47 | #include "compiler/shader_enums.h" |
| 48 | #include "util/macros.h" |
| 49 | #include "util/list.h" |
| 50 | #include "main/macros.h" |
Alex Smith | 621b341 | 2017-06-06 12:31:05 +0100 | [diff] [blame] | 51 | #include "vk_alloc.h" |
Dave Airlie | 4450f40 | 2016-10-14 13:36:45 +1000 | [diff] [blame] | 52 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 53 | #include "radv_radeon_winsys.h" |
| 54 | #include "ac_binary.h" |
| 55 | #include "ac_nir_to_llvm.h" |
Nicolai Hähnle | bd4493b | 2017-05-12 01:11:27 +0200 | [diff] [blame] | 56 | #include "ac_gpu_info.h" |
Nicolai Hähnle | dfc06d2 | 2017-05-10 23:01:00 +0200 | [diff] [blame] | 57 | #include "ac_surface.h" |
Bas Nieuwenhuizen | fb7e4e1 | 2017-03-05 20:58:31 +0100 | [diff] [blame] | 58 | #include "radv_debug.h" |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 59 | #include "radv_descriptor_set.h" |
| 60 | |
| 61 | #include <llvm-c/TargetMachine.h> |
| 62 | |
| 63 | /* Pre-declarations needed for WSI entrypoints */ |
| 64 | struct wl_surface; |
| 65 | struct wl_display; |
| 66 | typedef struct xcb_connection_t xcb_connection_t; |
| 67 | typedef uint32_t xcb_visualid_t; |
| 68 | typedef uint32_t xcb_window_t; |
| 69 | |
| 70 | #include <vulkan/vulkan.h> |
| 71 | #include <vulkan/vulkan_intel.h> |
| 72 | #include <vulkan/vk_icd.h> |
| 73 | |
| 74 | #include "radv_entrypoints.h" |
| 75 | |
Dave Airlie | 6c3bd1c | 2016-10-14 07:49:34 +0100 | [diff] [blame] | 76 | #include "wsi_common.h" |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 77 | |
| 78 | #define MAX_VBS 32 |
| 79 | #define MAX_VERTEX_ATTRIBS 32 |
| 80 | #define MAX_RTS 8 |
| 81 | #define MAX_VIEWPORTS 16 |
| 82 | #define MAX_SCISSORS 16 |
| 83 | #define MAX_PUSH_CONSTANTS_SIZE 128 |
Fredrik Höglund | c6487bc | 2017-03-29 18:12:44 +0200 | [diff] [blame] | 84 | #define MAX_PUSH_DESCRIPTORS 32 |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 85 | #define MAX_DYNAMIC_BUFFERS 16 |
Grazvydas Ignotas | cb89d19 | 2017-01-11 03:31:24 +0200 | [diff] [blame] | 86 | #define MAX_SAMPLES_LOG2 4 |
Dave Airlie | df61a05 | 2017-07-27 21:52:20 +0100 | [diff] [blame] | 87 | #define NUM_META_FS_KEYS 13 |
Bas Nieuwenhuizen | 5ae4de1 | 2017-01-16 21:25:10 +0100 | [diff] [blame] | 88 | #define RADV_MAX_DRM_DEVICES 8 |
Bas Nieuwenhuizen | e3265c1 | 2017-08-16 09:20:26 +0200 | [diff] [blame] | 89 | #define MAX_VIEWS 8 |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 90 | |
| 91 | #define NUM_DEPTH_CLEAR_PIPELINES 3 |
| 92 | |
Bas Nieuwenhuizen | 4ae84ef | 2016-12-08 22:28:21 +0100 | [diff] [blame] | 93 | enum radv_mem_heap { |
| 94 | RADV_MEM_HEAP_VRAM, |
| 95 | RADV_MEM_HEAP_VRAM_CPU_ACCESS, |
| 96 | RADV_MEM_HEAP_GTT, |
| 97 | RADV_MEM_HEAP_COUNT |
| 98 | }; |
| 99 | |
Bas Nieuwenhuizen | 53e1c97 | 2016-12-08 23:06:44 +0100 | [diff] [blame] | 100 | enum radv_mem_type { |
| 101 | RADV_MEM_TYPE_VRAM, |
| 102 | RADV_MEM_TYPE_GTT_WRITE_COMBINE, |
| 103 | RADV_MEM_TYPE_VRAM_CPU_ACCESS, |
| 104 | RADV_MEM_TYPE_GTT_CACHED, |
| 105 | RADV_MEM_TYPE_COUNT |
| 106 | }; |
| 107 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 108 | #define radv_printflike(a, b) __attribute__((__format__(__printf__, a, b))) |
| 109 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 110 | static inline uint32_t |
| 111 | align_u32(uint32_t v, uint32_t a) |
| 112 | { |
| 113 | assert(a != 0 && a == (a & -a)); |
| 114 | return (v + a - 1) & ~(a - 1); |
| 115 | } |
| 116 | |
| 117 | static inline uint32_t |
| 118 | align_u32_npot(uint32_t v, uint32_t a) |
| 119 | { |
| 120 | return (v + a - 1) / a * a; |
| 121 | } |
| 122 | |
| 123 | static inline uint64_t |
| 124 | align_u64(uint64_t v, uint64_t a) |
| 125 | { |
| 126 | assert(a != 0 && a == (a & -a)); |
| 127 | return (v + a - 1) & ~(a - 1); |
| 128 | } |
| 129 | |
| 130 | static inline int32_t |
| 131 | align_i32(int32_t v, int32_t a) |
| 132 | { |
| 133 | assert(a != 0 && a == (a & -a)); |
| 134 | return (v + a - 1) & ~(a - 1); |
| 135 | } |
| 136 | |
| 137 | /** Alignment must be a power of 2. */ |
| 138 | static inline bool |
| 139 | radv_is_aligned(uintmax_t n, uintmax_t a) |
| 140 | { |
| 141 | assert(a == (a & -a)); |
| 142 | return (n & (a - 1)) == 0; |
| 143 | } |
| 144 | |
| 145 | static inline uint32_t |
| 146 | round_up_u32(uint32_t v, uint32_t a) |
| 147 | { |
| 148 | return (v + a - 1) / a; |
| 149 | } |
| 150 | |
| 151 | static inline uint64_t |
| 152 | round_up_u64(uint64_t v, uint64_t a) |
| 153 | { |
| 154 | return (v + a - 1) / a; |
| 155 | } |
| 156 | |
| 157 | static inline uint32_t |
| 158 | radv_minify(uint32_t n, uint32_t levels) |
| 159 | { |
| 160 | if (unlikely(n == 0)) |
| 161 | return 0; |
| 162 | else |
Dave Airlie | c6f1077 | 2016-10-14 13:11:20 +1000 | [diff] [blame] | 163 | return MAX2(n >> levels, 1); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 164 | } |
| 165 | static inline float |
| 166 | radv_clamp_f(float f, float min, float max) |
| 167 | { |
| 168 | assert(min < max); |
| 169 | |
| 170 | if (f > max) |
| 171 | return max; |
| 172 | else if (f < min) |
| 173 | return min; |
| 174 | else |
| 175 | return f; |
| 176 | } |
| 177 | |
| 178 | static inline bool |
| 179 | radv_clear_mask(uint32_t *inout_mask, uint32_t clear_mask) |
| 180 | { |
| 181 | if (*inout_mask & clear_mask) { |
| 182 | *inout_mask &= ~clear_mask; |
| 183 | return true; |
| 184 | } else { |
| 185 | return false; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | #define for_each_bit(b, dword) \ |
| 190 | for (uint32_t __dword = (dword); \ |
| 191 | (b) = __builtin_ffs(__dword) - 1, __dword; \ |
| 192 | __dword &= ~(1 << (b))) |
| 193 | |
| 194 | #define typed_memcpy(dest, src, count) ({ \ |
Edward O'Callaghan | a77426f | 2016-12-07 10:30:48 +1100 | [diff] [blame] | 195 | STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \ |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 196 | memcpy((dest), (src), (count) * sizeof(*(src))); \ |
| 197 | }) |
| 198 | |
| 199 | #define zero(x) (memset(&(x), 0, sizeof(x))) |
| 200 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 201 | /* Whenever we generate an error, pass it through this function. Useful for |
| 202 | * debugging, where we can break on it. Only call at error site, not when |
| 203 | * propagating errors. Might be useful to plug in a stack trace here. |
| 204 | */ |
| 205 | |
| 206 | VkResult __vk_errorf(VkResult error, const char *file, int line, const char *format, ...); |
| 207 | |
| 208 | #ifdef DEBUG |
| 209 | #define vk_error(error) __vk_errorf(error, __FILE__, __LINE__, NULL); |
| 210 | #define vk_errorf(error, format, ...) __vk_errorf(error, __FILE__, __LINE__, format, ## __VA_ARGS__); |
| 211 | #else |
| 212 | #define vk_error(error) error |
| 213 | #define vk_errorf(error, format, ...) error |
| 214 | #endif |
| 215 | |
| 216 | void __radv_finishme(const char *file, int line, const char *format, ...) |
| 217 | radv_printflike(3, 4); |
| 218 | void radv_loge(const char *format, ...) radv_printflike(1, 2); |
| 219 | void radv_loge_v(const char *format, va_list va); |
| 220 | |
| 221 | /** |
| 222 | * Print a FINISHME message, including its source location. |
| 223 | */ |
| 224 | #define radv_finishme(format, ...) \ |
Emil Velikov | f3a1c17 | 2016-11-24 18:18:14 +0000 | [diff] [blame] | 225 | do { \ |
| 226 | static bool reported = false; \ |
| 227 | if (!reported) { \ |
| 228 | __radv_finishme(__FILE__, __LINE__, format, ##__VA_ARGS__); \ |
| 229 | reported = true; \ |
| 230 | } \ |
| 231 | } while (0) |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 232 | |
| 233 | /* A non-fatal assert. Useful for debugging. */ |
| 234 | #ifdef DEBUG |
| 235 | #define radv_assert(x) ({ \ |
| 236 | if (unlikely(!(x))) \ |
| 237 | fprintf(stderr, "%s:%d ASSERT: %s\n", __FILE__, __LINE__, #x); \ |
| 238 | }) |
| 239 | #else |
| 240 | #define radv_assert(x) |
| 241 | #endif |
| 242 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 243 | #define stub_return(v) \ |
| 244 | do { \ |
| 245 | radv_finishme("stub %s", __func__); \ |
| 246 | return (v); \ |
| 247 | } while (0) |
| 248 | |
| 249 | #define stub() \ |
| 250 | do { \ |
| 251 | radv_finishme("stub %s", __func__); \ |
| 252 | return; \ |
| 253 | } while (0) |
| 254 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 255 | void *radv_lookup_entrypoint(const char *name); |
| 256 | |
Andres Rodriguez | 1e1bddf | 2017-01-13 18:44:17 -0500 | [diff] [blame] | 257 | struct radv_extensions { |
| 258 | VkExtensionProperties *ext_array; |
| 259 | uint32_t num_ext; |
| 260 | }; |
| 261 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 262 | struct radv_physical_device { |
| 263 | VK_LOADER_DATA _loader_data; |
| 264 | |
| 265 | struct radv_instance * instance; |
| 266 | |
| 267 | struct radeon_winsys *ws; |
| 268 | struct radeon_info rad_info; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 269 | char path[20]; |
| 270 | const char * name; |
Andres Rodriguez | 14cad87 | 2017-07-12 18:45:31 -0400 | [diff] [blame] | 271 | uint8_t driver_uuid[VK_UUID_SIZE]; |
Bas Nieuwenhuizen | d515b42 | 2017-05-23 09:22:09 +0200 | [diff] [blame] | 272 | uint8_t device_uuid[VK_UUID_SIZE]; |
Andres Rodriguez | a973b9a | 2017-07-12 18:45:29 -0400 | [diff] [blame] | 273 | uint8_t cache_uuid[VK_UUID_SIZE]; |
Bas Nieuwenhuizen | 43ee491 | 2016-11-22 00:31:44 +0100 | [diff] [blame] | 274 | |
Dave Airlie | 0a44a68 | 2017-02-19 15:27:47 +1000 | [diff] [blame] | 275 | int local_fd; |
Dave Airlie | 6c3bd1c | 2016-10-14 07:49:34 +0100 | [diff] [blame] | 276 | struct wsi_device wsi_device; |
Andres Rodriguez | 1e1bddf | 2017-01-13 18:44:17 -0500 | [diff] [blame] | 277 | struct radv_extensions extensions; |
Dave Airlie | 67655cb | 2017-06-06 09:03:55 +1000 | [diff] [blame] | 278 | |
| 279 | bool has_rbplus; /* if RB+ register exist */ |
| 280 | bool rbplus_allowed; /* if RB+ is allowed */ |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 281 | }; |
| 282 | |
| 283 | struct radv_instance { |
| 284 | VK_LOADER_DATA _loader_data; |
| 285 | |
| 286 | VkAllocationCallbacks alloc; |
| 287 | |
| 288 | uint32_t apiVersion; |
| 289 | int physicalDeviceCount; |
Bas Nieuwenhuizen | 5ae4de1 | 2017-01-16 21:25:10 +0100 | [diff] [blame] | 290 | struct radv_physical_device physicalDevices[RADV_MAX_DRM_DEVICES]; |
Bas Nieuwenhuizen | 8bc39e2 | 2017-01-02 18:57:02 +0100 | [diff] [blame] | 291 | |
| 292 | uint64_t debug_flags; |
Dave Airlie | c246427 | 2017-05-09 04:17:30 +0100 | [diff] [blame] | 293 | uint64_t perftest_flags; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 294 | }; |
| 295 | |
| 296 | VkResult radv_init_wsi(struct radv_physical_device *physical_device); |
| 297 | void radv_finish_wsi(struct radv_physical_device *physical_device); |
| 298 | |
| 299 | struct cache_entry; |
| 300 | |
| 301 | struct radv_pipeline_cache { |
| 302 | struct radv_device * device; |
| 303 | pthread_mutex_t mutex; |
| 304 | |
| 305 | uint32_t total_size; |
| 306 | uint32_t table_size; |
| 307 | uint32_t kernel_count; |
| 308 | struct cache_entry ** hash_table; |
| 309 | bool modified; |
| 310 | |
| 311 | VkAllocationCallbacks alloc; |
| 312 | }; |
| 313 | |
| 314 | void |
| 315 | radv_pipeline_cache_init(struct radv_pipeline_cache *cache, |
| 316 | struct radv_device *device); |
| 317 | void |
| 318 | radv_pipeline_cache_finish(struct radv_pipeline_cache *cache); |
| 319 | void |
| 320 | radv_pipeline_cache_load(struct radv_pipeline_cache *cache, |
| 321 | const void *data, size_t size); |
| 322 | |
| 323 | struct radv_shader_variant * |
| 324 | radv_create_shader_variant_from_pipeline_cache(struct radv_device *device, |
| 325 | struct radv_pipeline_cache *cache, |
| 326 | const unsigned char *sha1); |
| 327 | |
| 328 | struct radv_shader_variant * |
Dave Airlie | 10c2b58 | 2017-03-20 13:24:02 +1000 | [diff] [blame] | 329 | radv_pipeline_cache_insert_shader(struct radv_pipeline_cache *cache, |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 330 | const unsigned char *sha1, |
| 331 | struct radv_shader_variant *variant, |
| 332 | const void *code, unsigned code_size); |
| 333 | |
| 334 | void radv_shader_variant_destroy(struct radv_device *device, |
| 335 | struct radv_shader_variant *variant); |
| 336 | |
| 337 | struct radv_meta_state { |
| 338 | VkAllocationCallbacks alloc; |
| 339 | |
| 340 | struct radv_pipeline_cache cache; |
| 341 | |
| 342 | /** |
| 343 | * Use array element `i` for images with `2^i` samples. |
| 344 | */ |
| 345 | struct { |
| 346 | VkRenderPass render_pass[NUM_META_FS_KEYS]; |
| 347 | struct radv_pipeline *color_pipelines[NUM_META_FS_KEYS]; |
| 348 | |
Dave Airlie | 3634dfd | 2017-01-17 06:37:36 +1000 | [diff] [blame] | 349 | VkRenderPass depthstencil_rp; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 350 | struct radv_pipeline *depth_only_pipeline[NUM_DEPTH_CLEAR_PIPELINES]; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 351 | struct radv_pipeline *stencil_only_pipeline[NUM_DEPTH_CLEAR_PIPELINES]; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 352 | struct radv_pipeline *depthstencil_pipeline[NUM_DEPTH_CLEAR_PIPELINES]; |
| 353 | } clear[1 + MAX_SAMPLES_LOG2]; |
| 354 | |
Dave Airlie | b29ea49 | 2017-04-19 10:34:37 +1000 | [diff] [blame] | 355 | VkPipelineLayout clear_color_p_layout; |
| 356 | VkPipelineLayout clear_depth_p_layout; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 357 | struct { |
| 358 | VkRenderPass render_pass[NUM_META_FS_KEYS]; |
| 359 | |
| 360 | /** Pipeline that blits from a 1D image. */ |
| 361 | VkPipeline pipeline_1d_src[NUM_META_FS_KEYS]; |
| 362 | |
| 363 | /** Pipeline that blits from a 2D image. */ |
| 364 | VkPipeline pipeline_2d_src[NUM_META_FS_KEYS]; |
| 365 | |
| 366 | /** Pipeline that blits from a 3D image. */ |
| 367 | VkPipeline pipeline_3d_src[NUM_META_FS_KEYS]; |
| 368 | |
| 369 | VkRenderPass depth_only_rp; |
| 370 | VkPipeline depth_only_1d_pipeline; |
| 371 | VkPipeline depth_only_2d_pipeline; |
| 372 | VkPipeline depth_only_3d_pipeline; |
| 373 | |
| 374 | VkRenderPass stencil_only_rp; |
| 375 | VkPipeline stencil_only_1d_pipeline; |
| 376 | VkPipeline stencil_only_2d_pipeline; |
| 377 | VkPipeline stencil_only_3d_pipeline; |
| 378 | VkPipelineLayout pipeline_layout; |
| 379 | VkDescriptorSetLayout ds_layout; |
| 380 | } blit; |
| 381 | |
| 382 | struct { |
| 383 | VkRenderPass render_passes[NUM_META_FS_KEYS]; |
| 384 | |
| 385 | VkPipelineLayout p_layouts[2]; |
| 386 | VkDescriptorSetLayout ds_layouts[2]; |
| 387 | VkPipeline pipelines[2][NUM_META_FS_KEYS]; |
| 388 | |
| 389 | VkRenderPass depth_only_rp; |
| 390 | VkPipeline depth_only_pipeline[2]; |
| 391 | |
| 392 | VkRenderPass stencil_only_rp; |
| 393 | VkPipeline stencil_only_pipeline[2]; |
| 394 | } blit2d; |
| 395 | |
| 396 | struct { |
| 397 | VkPipelineLayout img_p_layout; |
| 398 | VkDescriptorSetLayout img_ds_layout; |
| 399 | VkPipeline pipeline; |
| 400 | } itob; |
| 401 | struct { |
| 402 | VkRenderPass render_pass; |
| 403 | VkPipelineLayout img_p_layout; |
| 404 | VkDescriptorSetLayout img_ds_layout; |
| 405 | VkPipeline pipeline; |
| 406 | } btoi; |
Dave Airlie | ef5f59c | 2016-11-30 00:26:47 +0000 | [diff] [blame] | 407 | struct { |
| 408 | VkPipelineLayout img_p_layout; |
| 409 | VkDescriptorSetLayout img_ds_layout; |
| 410 | VkPipeline pipeline; |
| 411 | } itoi; |
Dave Airlie | f11ea87 | 2016-11-30 01:45:24 +0000 | [diff] [blame] | 412 | struct { |
| 413 | VkPipelineLayout img_p_layout; |
| 414 | VkDescriptorSetLayout img_ds_layout; |
| 415 | VkPipeline pipeline; |
| 416 | } cleari; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 417 | |
| 418 | struct { |
| 419 | VkPipeline pipeline; |
| 420 | VkRenderPass pass; |
| 421 | } resolve; |
| 422 | |
| 423 | struct { |
| 424 | VkDescriptorSetLayout ds_layout; |
| 425 | VkPipelineLayout p_layout; |
| 426 | struct { |
| 427 | VkPipeline pipeline; |
| 428 | VkPipeline i_pipeline; |
Dave Airlie | 588185e | 2017-04-20 04:42:26 +0100 | [diff] [blame] | 429 | VkPipeline srgb_pipeline; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 430 | } rc[MAX_SAMPLES_LOG2]; |
| 431 | } resolve_compute; |
| 432 | |
| 433 | struct { |
Dave Airlie | 69136f4 | 2017-04-27 01:47:22 +0100 | [diff] [blame] | 434 | VkDescriptorSetLayout ds_layout; |
| 435 | VkPipelineLayout p_layout; |
| 436 | |
| 437 | struct { |
| 438 | VkRenderPass render_pass[NUM_META_FS_KEYS]; |
| 439 | VkPipeline pipeline[NUM_META_FS_KEYS]; |
| 440 | } rc[MAX_SAMPLES_LOG2]; |
| 441 | } resolve_fragment; |
| 442 | |
| 443 | struct { |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 444 | VkPipeline decompress_pipeline; |
| 445 | VkPipeline resummarize_pipeline; |
| 446 | VkRenderPass pass; |
Alex Smith | 2e9a13b | 2017-08-03 15:32:46 +0100 | [diff] [blame] | 447 | } depth_decomp[1 + MAX_SAMPLES_LOG2]; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 448 | |
| 449 | struct { |
| 450 | VkPipeline cmask_eliminate_pipeline; |
| 451 | VkPipeline fmask_decompress_pipeline; |
| 452 | VkRenderPass pass; |
| 453 | } fast_clear_flush; |
| 454 | |
| 455 | struct { |
| 456 | VkPipelineLayout fill_p_layout; |
| 457 | VkPipelineLayout copy_p_layout; |
| 458 | VkDescriptorSetLayout fill_ds_layout; |
| 459 | VkDescriptorSetLayout copy_ds_layout; |
| 460 | VkPipeline fill_pipeline; |
| 461 | VkPipeline copy_pipeline; |
| 462 | } buffer; |
Bas Nieuwenhuizen | ce0c8cf | 2017-02-26 18:21:01 +0100 | [diff] [blame] | 463 | |
| 464 | struct { |
Bas Nieuwenhuizen | 8473193 | 2017-04-10 21:49:48 +0200 | [diff] [blame] | 465 | VkDescriptorSetLayout ds_layout; |
| 466 | VkPipelineLayout p_layout; |
Bas Nieuwenhuizen | ce0c8cf | 2017-02-26 18:21:01 +0100 | [diff] [blame] | 467 | VkPipeline occlusion_query_pipeline; |
Bas Nieuwenhuizen | 8475a14 | 2017-04-10 22:20:19 +0200 | [diff] [blame] | 468 | VkPipeline pipeline_statistics_query_pipeline; |
Bas Nieuwenhuizen | ce0c8cf | 2017-02-26 18:21:01 +0100 | [diff] [blame] | 469 | } query; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 470 | }; |
| 471 | |
Dave Airlie | c20701f | 2016-11-30 04:30:06 +0000 | [diff] [blame] | 472 | /* queue types */ |
| 473 | #define RADV_QUEUE_GENERAL 0 |
| 474 | #define RADV_QUEUE_COMPUTE 1 |
| 475 | #define RADV_QUEUE_TRANSFER 2 |
| 476 | |
| 477 | #define RADV_MAX_QUEUE_FAMILIES 3 |
| 478 | |
Dave Airlie | 94a7434 | 2016-12-01 00:05:29 +0000 | [diff] [blame] | 479 | enum ring_type radv_queue_family_to_ring(int f); |
| 480 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 481 | struct radv_queue { |
| 482 | VK_LOADER_DATA _loader_data; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 483 | struct radv_device * device; |
Andres Rodriguez | 0eb8b6a | 2017-01-13 18:44:15 -0500 | [diff] [blame] | 484 | struct radeon_winsys_ctx *hw_ctx; |
Dave Airlie | c20701f | 2016-11-30 04:30:06 +0000 | [diff] [blame] | 485 | int queue_family_index; |
| 486 | int queue_idx; |
Bas Nieuwenhuizen | c4d7b9c | 2017-01-29 13:53:05 +0100 | [diff] [blame] | 487 | |
| 488 | uint32_t scratch_size; |
| 489 | uint32_t compute_scratch_size; |
Dave Airlie | 1fa5b75 | 2017-01-20 11:06:52 +1000 | [diff] [blame] | 490 | uint32_t esgs_ring_size; |
| 491 | uint32_t gsvs_ring_size; |
Dave Airlie | 46e52df | 2017-03-30 08:02:14 +0100 | [diff] [blame] | 492 | bool has_tess_rings; |
Dave Airlie | 1171b30 | 2017-04-03 04:38:12 +0100 | [diff] [blame] | 493 | bool has_sample_positions; |
Bas Nieuwenhuizen | c4d7b9c | 2017-01-29 13:53:05 +0100 | [diff] [blame] | 494 | |
| 495 | struct radeon_winsys_bo *scratch_bo; |
| 496 | struct radeon_winsys_bo *descriptor_bo; |
| 497 | struct radeon_winsys_bo *compute_scratch_bo; |
Dave Airlie | 1fa5b75 | 2017-01-20 11:06:52 +1000 | [diff] [blame] | 498 | struct radeon_winsys_bo *esgs_ring_bo; |
| 499 | struct radeon_winsys_bo *gsvs_ring_bo; |
Dave Airlie | 46e52df | 2017-03-30 08:02:14 +0100 | [diff] [blame] | 500 | struct radeon_winsys_bo *tess_factor_ring_bo; |
| 501 | struct radeon_winsys_bo *tess_offchip_ring_bo; |
Bas Nieuwenhuizen | 5241fb0 | 2017-02-20 09:26:00 +0100 | [diff] [blame] | 502 | struct radeon_winsys_cs *initial_preamble_cs; |
| 503 | struct radeon_winsys_cs *continue_preamble_cs; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 504 | }; |
| 505 | |
| 506 | struct radv_device { |
| 507 | VK_LOADER_DATA _loader_data; |
| 508 | |
| 509 | VkAllocationCallbacks alloc; |
| 510 | |
| 511 | struct radv_instance * instance; |
| 512 | struct radeon_winsys *ws; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 513 | |
| 514 | struct radv_meta_state meta_state; |
Dave Airlie | c20701f | 2016-11-30 04:30:06 +0000 | [diff] [blame] | 515 | |
| 516 | struct radv_queue *queues[RADV_MAX_QUEUE_FAMILIES]; |
| 517 | int queue_count[RADV_MAX_QUEUE_FAMILIES]; |
Bas Nieuwenhuizen | f2523eb | 2016-12-17 21:53:38 +0100 | [diff] [blame] | 518 | struct radeon_winsys_cs *empty_cs[RADV_MAX_QUEUE_FAMILIES]; |
Bas Nieuwenhuizen | 5241fb0 | 2017-02-20 09:26:00 +0100 | [diff] [blame] | 519 | struct radeon_winsys_cs *flush_cs[RADV_MAX_QUEUE_FAMILIES]; |
Dave Airlie | a524704 | 2017-05-03 07:13:21 +1000 | [diff] [blame] | 520 | struct radeon_winsys_cs *flush_shader_cs[RADV_MAX_QUEUE_FAMILIES]; |
Bas Nieuwenhuizen | 8bc39e2 | 2017-01-02 18:57:02 +0100 | [diff] [blame] | 521 | uint64_t debug_flags; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 522 | |
Bas Nieuwenhuizen | ccff93e | 2017-01-29 15:20:03 +0100 | [diff] [blame] | 523 | bool llvm_supports_spill; |
Dave Airlie | bbfb62d | 2017-03-30 07:58:22 +0100 | [diff] [blame] | 524 | bool has_distributed_tess; |
| 525 | uint32_t tess_offchip_block_dw_size; |
Bas Nieuwenhuizen | ccff93e | 2017-01-29 15:20:03 +0100 | [diff] [blame] | 526 | uint32_t scratch_waves; |
Dave Airlie | 68c5da7 | 2017-01-18 13:54:17 +1000 | [diff] [blame] | 527 | |
| 528 | uint32_t gs_table_depth; |
| 529 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 530 | /* MSAA sample locations. |
| 531 | * The first index is the sample index. |
| 532 | * The second index is the coordinate: X, Y. */ |
| 533 | float sample_locations_1x[1][2]; |
| 534 | float sample_locations_2x[2][2]; |
| 535 | float sample_locations_4x[4][2]; |
| 536 | float sample_locations_8x[8][2]; |
| 537 | float sample_locations_16x[16][2]; |
Bas Nieuwenhuizen | 97dfff5 | 2016-12-23 23:51:18 +0100 | [diff] [blame] | 538 | |
Dave Airlie | 592069c | 2017-02-13 04:00:24 +0000 | [diff] [blame] | 539 | /* CIK and later */ |
| 540 | uint32_t gfx_init_size_dw; |
| 541 | struct radeon_winsys_bo *gfx_init; |
| 542 | |
Bas Nieuwenhuizen | 97dfff5 | 2016-12-23 23:51:18 +0100 | [diff] [blame] | 543 | struct radeon_winsys_bo *trace_bo; |
| 544 | uint32_t *trace_id_ptr; |
Bas Nieuwenhuizen | 8406f79 | 2017-01-16 21:23:48 +0100 | [diff] [blame] | 545 | |
| 546 | struct radv_physical_device *physical_device; |
Timothy Arceri | 315e8a9 | 2017-03-15 14:14:24 +1100 | [diff] [blame] | 547 | |
| 548 | /* Backup in-memory cache to be used if the app doesn't provide one */ |
| 549 | struct radv_pipeline_cache * mem_cache; |
Dave Airlie | f8d5b37 | 2017-07-07 06:56:57 +0100 | [diff] [blame] | 550 | |
Dave Airlie | 1e696b9 | 2017-08-04 06:54:15 +0100 | [diff] [blame] | 551 | /* |
| 552 | * use different counters so MSAA MRTs get consecutive surface indices, |
| 553 | * even if MASK is allocated in between. |
| 554 | */ |
Dave Airlie | f8d5b37 | 2017-07-07 06:56:57 +0100 | [diff] [blame] | 555 | uint32_t image_mrt_offset_counter; |
Dave Airlie | 1e696b9 | 2017-08-04 06:54:15 +0100 | [diff] [blame] | 556 | uint32_t fmask_mrt_offset_counter; |
Bas Nieuwenhuizen | c9d4b57 | 2017-03-12 22:43:51 +0100 | [diff] [blame] | 557 | struct list_head shader_slabs; |
| 558 | mtx_t shader_slab_mutex; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 559 | }; |
| 560 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 561 | struct radv_device_memory { |
| 562 | struct radeon_winsys_bo *bo; |
Dave Airlie | 15f4702 | 2017-02-26 23:52:08 +0000 | [diff] [blame] | 563 | /* for dedicated allocations */ |
| 564 | struct radv_image *image; |
| 565 | struct radv_buffer *buffer; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 566 | uint32_t type_index; |
| 567 | VkDeviceSize map_size; |
| 568 | void * map; |
| 569 | }; |
| 570 | |
| 571 | |
| 572 | struct radv_descriptor_range { |
| 573 | uint64_t va; |
| 574 | uint32_t size; |
| 575 | }; |
| 576 | |
| 577 | struct radv_descriptor_set { |
| 578 | const struct radv_descriptor_set_layout *layout; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 579 | uint32_t size; |
| 580 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 581 | struct radeon_winsys_bo *bo; |
| 582 | uint64_t va; |
| 583 | uint32_t *mapped_ptr; |
| 584 | struct radv_descriptor_range *dynamic_descriptors; |
Bas Nieuwenhuizen | d5bf4c7 | 2017-02-16 21:23:58 +0100 | [diff] [blame] | 585 | |
| 586 | struct list_head vram_list; |
| 587 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 588 | struct radeon_winsys_bo *descriptors[0]; |
| 589 | }; |
| 590 | |
Fredrik Höglund | c6487bc | 2017-03-29 18:12:44 +0200 | [diff] [blame] | 591 | struct radv_push_descriptor_set |
| 592 | { |
| 593 | struct radv_descriptor_set set; |
| 594 | uint32_t capacity; |
| 595 | }; |
| 596 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 597 | struct radv_descriptor_pool { |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 598 | struct radeon_winsys_bo *bo; |
| 599 | uint8_t *mapped_ptr; |
| 600 | uint64_t current_offset; |
| 601 | uint64_t size; |
| 602 | |
Bas Nieuwenhuizen | d5bf4c7 | 2017-02-16 21:23:58 +0100 | [diff] [blame] | 603 | struct list_head vram_list; |
Bas Nieuwenhuizen | 126d5ad | 2017-04-17 02:14:06 +0200 | [diff] [blame] | 604 | |
| 605 | uint8_t *host_memory_base; |
| 606 | uint8_t *host_memory_ptr; |
| 607 | uint8_t *host_memory_end; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 608 | }; |
| 609 | |
Fredrik Höglund | c1f8c83 | 2017-03-29 19:19:47 +0200 | [diff] [blame] | 610 | struct radv_descriptor_update_template_entry { |
| 611 | VkDescriptorType descriptor_type; |
| 612 | |
| 613 | /* The number of descriptors to update */ |
Bas Nieuwenhuizen | e20eb91 | 2017-04-13 23:49:00 +0200 | [diff] [blame] | 614 | uint32_t descriptor_count; |
Fredrik Höglund | c1f8c83 | 2017-03-29 19:19:47 +0200 | [diff] [blame] | 615 | |
| 616 | /* Into mapped_ptr or dynamic_descriptors, in units of the respective array */ |
Bas Nieuwenhuizen | e20eb91 | 2017-04-13 23:49:00 +0200 | [diff] [blame] | 617 | uint32_t dst_offset; |
Fredrik Höglund | c1f8c83 | 2017-03-29 19:19:47 +0200 | [diff] [blame] | 618 | |
| 619 | /* In dwords. Not valid/used for dynamic descriptors */ |
Bas Nieuwenhuizen | e20eb91 | 2017-04-13 23:49:00 +0200 | [diff] [blame] | 620 | uint32_t dst_stride; |
Fredrik Höglund | c1f8c83 | 2017-03-29 19:19:47 +0200 | [diff] [blame] | 621 | |
Bas Nieuwenhuizen | e20eb91 | 2017-04-13 23:49:00 +0200 | [diff] [blame] | 622 | uint32_t buffer_offset; |
Fredrik Höglund | c1f8c83 | 2017-03-29 19:19:47 +0200 | [diff] [blame] | 623 | |
| 624 | /* Only valid for combined image samplers and samplers */ |
| 625 | uint16_t has_sampler; |
| 626 | |
| 627 | /* In bytes */ |
| 628 | size_t src_offset; |
| 629 | size_t src_stride; |
| 630 | |
| 631 | /* For push descriptors */ |
Bas Nieuwenhuizen | bd91caf | 2017-04-12 00:37:06 +0200 | [diff] [blame] | 632 | const uint32_t *immutable_samplers; |
Fredrik Höglund | c1f8c83 | 2017-03-29 19:19:47 +0200 | [diff] [blame] | 633 | }; |
| 634 | |
| 635 | struct radv_descriptor_update_template { |
| 636 | uint32_t entry_count; |
| 637 | struct radv_descriptor_update_template_entry entry[0]; |
| 638 | }; |
| 639 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 640 | struct radv_buffer { |
| 641 | struct radv_device * device; |
| 642 | VkDeviceSize size; |
| 643 | |
| 644 | VkBufferUsageFlags usage; |
Bas Nieuwenhuizen | ef0e505 | 2017-02-04 11:15:59 +0100 | [diff] [blame] | 645 | VkBufferCreateFlags flags; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 646 | |
| 647 | /* Set when bound */ |
| 648 | struct radeon_winsys_bo * bo; |
| 649 | VkDeviceSize offset; |
| 650 | }; |
| 651 | |
| 652 | |
| 653 | enum radv_cmd_dirty_bits { |
| 654 | RADV_CMD_DIRTY_DYNAMIC_VIEWPORT = 1 << 0, /* VK_DYNAMIC_STATE_VIEWPORT */ |
| 655 | RADV_CMD_DIRTY_DYNAMIC_SCISSOR = 1 << 1, /* VK_DYNAMIC_STATE_SCISSOR */ |
| 656 | RADV_CMD_DIRTY_DYNAMIC_LINE_WIDTH = 1 << 2, /* VK_DYNAMIC_STATE_LINE_WIDTH */ |
| 657 | RADV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS = 1 << 3, /* VK_DYNAMIC_STATE_DEPTH_BIAS */ |
| 658 | RADV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS = 1 << 4, /* VK_DYNAMIC_STATE_BLEND_CONSTANTS */ |
| 659 | RADV_CMD_DIRTY_DYNAMIC_DEPTH_BOUNDS = 1 << 5, /* VK_DYNAMIC_STATE_DEPTH_BOUNDS */ |
| 660 | RADV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK = 1 << 6, /* VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK */ |
| 661 | RADV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK = 1 << 7, /* VK_DYNAMIC_STATE_STENCIL_WRITE_MASK */ |
| 662 | RADV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE = 1 << 8, /* VK_DYNAMIC_STATE_STENCIL_REFERENCE */ |
| 663 | RADV_CMD_DIRTY_DYNAMIC_ALL = (1 << 9) - 1, |
| 664 | RADV_CMD_DIRTY_PIPELINE = 1 << 9, |
| 665 | RADV_CMD_DIRTY_INDEX_BUFFER = 1 << 10, |
| 666 | RADV_CMD_DIRTY_RENDER_TARGETS = 1 << 11, |
| 667 | }; |
| 668 | typedef uint32_t radv_cmd_dirty_mask_t; |
| 669 | |
| 670 | enum radv_cmd_flush_bits { |
| 671 | RADV_CMD_FLAG_INV_ICACHE = 1 << 0, |
| 672 | /* SMEM L1, other names: KCACHE, constant cache, DCACHE, data cache */ |
| 673 | RADV_CMD_FLAG_INV_SMEM_L1 = 1 << 1, |
| 674 | /* VMEM L1 can optionally be bypassed (GLC=1). Other names: TC L1 */ |
| 675 | RADV_CMD_FLAG_INV_VMEM_L1 = 1 << 2, |
| 676 | /* Used by everything except CB/DB, can be bypassed (SLC=1). Other names: TC L2 */ |
| 677 | RADV_CMD_FLAG_INV_GLOBAL_L2 = 1 << 3, |
Bas Nieuwenhuizen | 66e12d4 | 2017-03-06 01:28:53 +0100 | [diff] [blame] | 678 | /* Same as above, but only writes back and doesn't invalidate */ |
| 679 | RADV_CMD_FLAG_WRITEBACK_GLOBAL_L2 = 1 << 4, |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 680 | /* Framebuffer caches */ |
Bas Nieuwenhuizen | 66e12d4 | 2017-03-06 01:28:53 +0100 | [diff] [blame] | 681 | RADV_CMD_FLAG_FLUSH_AND_INV_CB_META = 1 << 5, |
| 682 | RADV_CMD_FLAG_FLUSH_AND_INV_DB_META = 1 << 6, |
| 683 | RADV_CMD_FLAG_FLUSH_AND_INV_DB = 1 << 7, |
| 684 | RADV_CMD_FLAG_FLUSH_AND_INV_CB = 1 << 8, |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 685 | /* Engine synchronization. */ |
Bas Nieuwenhuizen | 66e12d4 | 2017-03-06 01:28:53 +0100 | [diff] [blame] | 686 | RADV_CMD_FLAG_VS_PARTIAL_FLUSH = 1 << 9, |
| 687 | RADV_CMD_FLAG_PS_PARTIAL_FLUSH = 1 << 10, |
| 688 | RADV_CMD_FLAG_CS_PARTIAL_FLUSH = 1 << 11, |
| 689 | RADV_CMD_FLAG_VGT_FLUSH = 1 << 12, |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 690 | |
| 691 | RADV_CMD_FLUSH_AND_INV_FRAMEBUFFER = (RADV_CMD_FLAG_FLUSH_AND_INV_CB | |
| 692 | RADV_CMD_FLAG_FLUSH_AND_INV_CB_META | |
| 693 | RADV_CMD_FLAG_FLUSH_AND_INV_DB | |
| 694 | RADV_CMD_FLAG_FLUSH_AND_INV_DB_META) |
| 695 | }; |
| 696 | |
| 697 | struct radv_vertex_binding { |
| 698 | struct radv_buffer * buffer; |
| 699 | VkDeviceSize offset; |
| 700 | }; |
| 701 | |
| 702 | struct radv_dynamic_state { |
| 703 | struct { |
| 704 | uint32_t count; |
| 705 | VkViewport viewports[MAX_VIEWPORTS]; |
| 706 | } viewport; |
| 707 | |
| 708 | struct { |
| 709 | uint32_t count; |
| 710 | VkRect2D scissors[MAX_SCISSORS]; |
| 711 | } scissor; |
| 712 | |
| 713 | float line_width; |
| 714 | |
| 715 | struct { |
| 716 | float bias; |
| 717 | float clamp; |
| 718 | float slope; |
| 719 | } depth_bias; |
| 720 | |
| 721 | float blend_constants[4]; |
| 722 | |
| 723 | struct { |
| 724 | float min; |
| 725 | float max; |
| 726 | } depth_bounds; |
| 727 | |
| 728 | struct { |
| 729 | uint32_t front; |
| 730 | uint32_t back; |
| 731 | } stencil_compare_mask; |
| 732 | |
| 733 | struct { |
| 734 | uint32_t front; |
| 735 | uint32_t back; |
| 736 | } stencil_write_mask; |
| 737 | |
| 738 | struct { |
| 739 | uint32_t front; |
| 740 | uint32_t back; |
| 741 | } stencil_reference; |
| 742 | }; |
| 743 | |
| 744 | extern const struct radv_dynamic_state default_dynamic_state; |
| 745 | |
| 746 | void radv_dynamic_state_copy(struct radv_dynamic_state *dest, |
| 747 | const struct radv_dynamic_state *src, |
| 748 | uint32_t copy_mask); |
| 749 | /** |
| 750 | * Attachment state when recording a renderpass instance. |
| 751 | * |
| 752 | * The clear value is valid only if there exists a pending clear. |
| 753 | */ |
| 754 | struct radv_attachment_state { |
| 755 | VkImageAspectFlags pending_clear_aspects; |
Bas Nieuwenhuizen | 2e86f6b | 2017-08-16 08:59:41 +0200 | [diff] [blame] | 756 | uint32_t cleared_views; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 757 | VkClearValue clear_value; |
| 758 | VkImageLayout current_layout; |
| 759 | }; |
| 760 | |
| 761 | struct radv_cmd_state { |
| 762 | uint32_t vb_dirty; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 763 | radv_cmd_dirty_mask_t dirty; |
Fredrik Höglund | c6487bc | 2017-03-29 18:12:44 +0200 | [diff] [blame] | 764 | bool push_descriptors_dirty; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 765 | |
| 766 | struct radv_pipeline * pipeline; |
| 767 | struct radv_pipeline * emitted_pipeline; |
| 768 | struct radv_pipeline * compute_pipeline; |
| 769 | struct radv_pipeline * emitted_compute_pipeline; |
| 770 | struct radv_framebuffer * framebuffer; |
| 771 | struct radv_render_pass * pass; |
| 772 | const struct radv_subpass * subpass; |
| 773 | struct radv_dynamic_state dynamic; |
| 774 | struct radv_vertex_binding vertex_bindings[MAX_VBS]; |
| 775 | struct radv_descriptor_set * descriptors[MAX_SETS]; |
| 776 | struct radv_attachment_state * attachments; |
| 777 | VkRect2D render_area; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 778 | uint32_t index_type; |
Dave Airlie | 00fe30f | 2017-06-07 09:14:54 +1000 | [diff] [blame] | 779 | uint64_t index_va; |
| 780 | uint32_t max_index_count; |
Alex Smith | 4603bea | 2017-04-12 09:20:42 +0100 | [diff] [blame] | 781 | int32_t last_primitive_reset_en; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 782 | uint32_t last_primitive_reset_index; |
| 783 | enum radv_cmd_flush_bits flush_bits; |
| 784 | unsigned active_occlusion_queries; |
| 785 | float offset_scale; |
Dave Airlie | 85118a1 | 2016-11-28 00:42:56 +0000 | [diff] [blame] | 786 | uint32_t descriptors_dirty; |
Bas Nieuwenhuizen | 97dfff5 | 2016-12-23 23:51:18 +0100 | [diff] [blame] | 787 | uint32_t trace_id; |
Dave Airlie | 3360dbe | 2017-02-13 07:30:29 +0000 | [diff] [blame] | 788 | uint32_t last_ia_multi_vgt_param; |
Dave Airlie | a6c2001 | 2017-06-26 02:13:24 +0100 | [diff] [blame] | 789 | bool predicating; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 790 | }; |
Dave Airlie | 94a7434 | 2016-12-01 00:05:29 +0000 | [diff] [blame] | 791 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 792 | struct radv_cmd_pool { |
| 793 | VkAllocationCallbacks alloc; |
| 794 | struct list_head cmd_buffers; |
Bas Nieuwenhuizen | 682248d | 2017-03-05 22:25:20 +0100 | [diff] [blame] | 795 | struct list_head free_cmd_buffers; |
Dave Airlie | 94a7434 | 2016-12-01 00:05:29 +0000 | [diff] [blame] | 796 | uint32_t queue_family_index; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 797 | }; |
| 798 | |
| 799 | struct radv_cmd_buffer_upload { |
| 800 | uint8_t *map; |
| 801 | unsigned offset; |
| 802 | uint64_t size; |
| 803 | struct radeon_winsys_bo *upload_bo; |
| 804 | struct list_head list; |
| 805 | }; |
| 806 | |
| 807 | struct radv_cmd_buffer { |
| 808 | VK_LOADER_DATA _loader_data; |
| 809 | |
| 810 | struct radv_device * device; |
| 811 | |
| 812 | struct radv_cmd_pool * pool; |
| 813 | struct list_head pool_link; |
| 814 | |
| 815 | VkCommandBufferUsageFlags usage_flags; |
| 816 | VkCommandBufferLevel level; |
| 817 | struct radeon_winsys_cs *cs; |
| 818 | struct radv_cmd_state state; |
Dave Airlie | 94a7434 | 2016-12-01 00:05:29 +0000 | [diff] [blame] | 819 | uint32_t queue_family_index; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 820 | |
| 821 | uint8_t push_constants[MAX_PUSH_CONSTANTS_SIZE]; |
Fredrik Höglund | 71bb1a9 | 2017-03-07 01:53:21 +0100 | [diff] [blame] | 822 | uint32_t dynamic_buffers[4 * MAX_DYNAMIC_BUFFERS]; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 823 | VkShaderStageFlags push_constant_stages; |
Fredrik Höglund | c6487bc | 2017-03-29 18:12:44 +0200 | [diff] [blame] | 824 | struct radv_push_descriptor_set push_descriptors; |
Fredrik Höglund | f95caae | 2017-04-14 00:26:58 +0200 | [diff] [blame] | 825 | struct radv_descriptor_set meta_push_descriptors; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 826 | |
| 827 | struct radv_cmd_buffer_upload upload; |
| 828 | |
Bas Nieuwenhuizen | ccff93e | 2017-01-29 15:20:03 +0100 | [diff] [blame] | 829 | uint32_t scratch_size_needed; |
| 830 | uint32_t compute_scratch_size_needed; |
Dave Airlie | 1fa5b75 | 2017-01-20 11:06:52 +1000 | [diff] [blame] | 831 | uint32_t esgs_ring_size_needed; |
| 832 | uint32_t gsvs_ring_size_needed; |
Dave Airlie | 46e52df | 2017-03-30 08:02:14 +0100 | [diff] [blame] | 833 | bool tess_rings_needed; |
Dave Airlie | 1171b30 | 2017-04-03 04:38:12 +0100 | [diff] [blame] | 834 | bool sample_positions_needed; |
Dave Airlie | 1fa5b75 | 2017-01-20 11:06:52 +1000 | [diff] [blame] | 835 | |
Samuel Pitoiset | 2bc3d65 | 2017-08-25 16:10:30 +0200 | [diff] [blame^] | 836 | VkResult record_result; |
Dave Airlie | ce0f692 | 2017-05-02 10:32:02 +1000 | [diff] [blame] | 837 | |
Dave Airlie | 1fa5b75 | 2017-01-20 11:06:52 +1000 | [diff] [blame] | 838 | int ring_offsets_idx; /* just used for verification */ |
Dave Airlie | c2fbeb7 | 2017-06-06 09:01:48 +1000 | [diff] [blame] | 839 | uint32_t gfx9_fence_offset; |
| 840 | struct radeon_winsys_bo *gfx9_fence_bo; |
| 841 | uint32_t gfx9_fence_idx; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 842 | }; |
| 843 | |
| 844 | struct radv_image; |
| 845 | |
Dave Airlie | 94a7434 | 2016-12-01 00:05:29 +0000 | [diff] [blame] | 846 | bool radv_cmd_buffer_uses_mec(struct radv_cmd_buffer *cmd_buffer); |
| 847 | |
Dave Airlie | 604e562 | 2017-02-13 03:35:37 +0000 | [diff] [blame] | 848 | void si_init_compute(struct radv_cmd_buffer *cmd_buffer); |
| 849 | void si_init_config(struct radv_cmd_buffer *cmd_buffer); |
Dave Airlie | 592069c | 2017-02-13 04:00:24 +0000 | [diff] [blame] | 850 | |
| 851 | void cik_create_gfx_config(struct radv_device *device); |
| 852 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 853 | void si_write_viewport(struct radeon_winsys_cs *cs, int first_vp, |
| 854 | int count, const VkViewport *viewports); |
| 855 | void si_write_scissors(struct radeon_winsys_cs *cs, int first, |
Bas Nieuwenhuizen | 0f3de89 | 2017-03-01 09:32:19 +0100 | [diff] [blame] | 856 | int count, const VkRect2D *scissors, |
| 857 | const VkViewport *viewports, bool can_use_guardband); |
Dave Airlie | 3360dbe | 2017-02-13 07:30:29 +0000 | [diff] [blame] | 858 | uint32_t si_get_ia_multi_vgt_param(struct radv_cmd_buffer *cmd_buffer, |
Dave Airlie | ae0551b | 2017-03-28 05:53:50 +1000 | [diff] [blame] | 859 | bool instanced_draw, bool indirect_draw, |
| 860 | uint32_t draw_vertex_count); |
Dave Airlie | ad61eac | 2017-06-01 05:24:34 +0100 | [diff] [blame] | 861 | void si_cs_emit_write_event_eop(struct radeon_winsys_cs *cs, |
Dave Airlie | a6c2001 | 2017-06-26 02:13:24 +0100 | [diff] [blame] | 862 | bool predicated, |
Dave Airlie | ad61eac | 2017-06-01 05:24:34 +0100 | [diff] [blame] | 863 | enum chip_class chip_class, |
| 864 | bool is_mec, |
| 865 | unsigned event, unsigned event_flags, |
| 866 | unsigned data_sel, |
| 867 | uint64_t va, |
| 868 | uint32_t old_fence, |
| 869 | uint32_t new_fence); |
| 870 | |
Dave Airlie | 7205431 | 2017-06-01 05:12:19 +0100 | [diff] [blame] | 871 | void si_emit_wait_fence(struct radeon_winsys_cs *cs, |
Dave Airlie | a6c2001 | 2017-06-26 02:13:24 +0100 | [diff] [blame] | 872 | bool predicated, |
Dave Airlie | 7205431 | 2017-06-01 05:12:19 +0100 | [diff] [blame] | 873 | uint64_t va, uint32_t ref, |
| 874 | uint32_t mask); |
Bas Nieuwenhuizen | 5241fb0 | 2017-02-20 09:26:00 +0100 | [diff] [blame] | 875 | void si_cs_emit_cache_flush(struct radeon_winsys_cs *cs, |
Dave Airlie | a6c2001 | 2017-06-26 02:13:24 +0100 | [diff] [blame] | 876 | bool predicated, |
Dave Airlie | c2fbeb7 | 2017-06-06 09:01:48 +1000 | [diff] [blame] | 877 | enum chip_class chip_class, |
| 878 | uint32_t *fence_ptr, uint64_t va, |
| 879 | bool is_mec, |
| 880 | enum radv_cmd_flush_bits flush_bits); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 881 | void si_emit_cache_flush(struct radv_cmd_buffer *cmd_buffer); |
Dave Airlie | 9ee6746 | 2017-03-02 21:39:10 +0000 | [diff] [blame] | 882 | void si_emit_set_predication_state(struct radv_cmd_buffer *cmd_buffer, uint64_t va); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 883 | void si_cp_dma_buffer_copy(struct radv_cmd_buffer *cmd_buffer, |
| 884 | uint64_t src_va, uint64_t dest_va, |
| 885 | uint64_t size); |
Bas Nieuwenhuizen | 1e11653 | 2017-04-19 22:32:16 +0200 | [diff] [blame] | 886 | void si_cp_dma_prefetch(struct radv_cmd_buffer *cmd_buffer, uint64_t va, |
| 887 | unsigned size); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 888 | void si_cp_dma_clear_buffer(struct radv_cmd_buffer *cmd_buffer, uint64_t va, |
| 889 | uint64_t size, unsigned value); |
| 890 | void radv_set_db_count_control(struct radv_cmd_buffer *cmd_buffer); |
| 891 | void radv_bind_descriptor_set(struct radv_cmd_buffer *cmd_buffer, |
| 892 | struct radv_descriptor_set *set, |
| 893 | unsigned idx); |
| 894 | bool |
| 895 | radv_cmd_buffer_upload_alloc(struct radv_cmd_buffer *cmd_buffer, |
| 896 | unsigned size, |
| 897 | unsigned alignment, |
| 898 | unsigned *out_offset, |
| 899 | void **ptr); |
| 900 | void |
| 901 | radv_cmd_buffer_set_subpass(struct radv_cmd_buffer *cmd_buffer, |
| 902 | const struct radv_subpass *subpass, |
| 903 | bool transitions); |
| 904 | bool |
| 905 | radv_cmd_buffer_upload_data(struct radv_cmd_buffer *cmd_buffer, |
| 906 | unsigned size, unsigned alignmnet, |
| 907 | const void *data, unsigned *out_offset); |
| 908 | void |
| 909 | radv_emit_framebuffer_state(struct radv_cmd_buffer *cmd_buffer); |
| 910 | void radv_cmd_buffer_clear_subpass(struct radv_cmd_buffer *cmd_buffer); |
| 911 | void radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer); |
Dave Airlie | 19be95f | 2017-05-04 04:02:08 +0100 | [diff] [blame] | 912 | void radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer); |
Dave Airlie | 69136f4 | 2017-04-27 01:47:22 +0100 | [diff] [blame] | 913 | void radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 914 | void radv_cayman_emit_msaa_sample_locs(struct radeon_winsys_cs *cs, int nr_samples); |
| 915 | unsigned radv_cayman_get_maxdist(int log_samples); |
| 916 | void radv_device_init_msaa(struct radv_device *device); |
| 917 | void radv_set_depth_clear_regs(struct radv_cmd_buffer *cmd_buffer, |
| 918 | struct radv_image *image, |
| 919 | VkClearDepthStencilValue ds_clear_value, |
| 920 | VkImageAspectFlags aspects); |
| 921 | void radv_set_color_clear_regs(struct radv_cmd_buffer *cmd_buffer, |
| 922 | struct radv_image *image, |
| 923 | int idx, |
| 924 | uint32_t color_values[2]); |
Dave Airlie | 9ee6746 | 2017-03-02 21:39:10 +0000 | [diff] [blame] | 925 | void radv_set_dcc_need_cmask_elim_pred(struct radv_cmd_buffer *cmd_buffer, |
| 926 | struct radv_image *image, |
| 927 | bool value); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 928 | void radv_fill_buffer(struct radv_cmd_buffer *cmd_buffer, |
| 929 | struct radeon_winsys_bo *bo, |
| 930 | uint64_t offset, uint64_t size, uint32_t value); |
Bas Nieuwenhuizen | 97dfff5 | 2016-12-23 23:51:18 +0100 | [diff] [blame] | 931 | void radv_cmd_buffer_trace_emit(struct radv_cmd_buffer *cmd_buffer); |
Dave Airlie | 15f4702 | 2017-02-26 23:52:08 +0000 | [diff] [blame] | 932 | bool radv_get_memory_fd(struct radv_device *device, |
| 933 | struct radv_device_memory *memory, |
| 934 | int *pFD); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 935 | /* |
| 936 | * Takes x,y,z as exact numbers of invocations, instead of blocks. |
| 937 | * |
| 938 | * Limitations: Can't call normal dispatch functions without binding or rebinding |
| 939 | * the compute pipeline. |
| 940 | */ |
| 941 | void radv_unaligned_dispatch( |
| 942 | struct radv_cmd_buffer *cmd_buffer, |
| 943 | uint32_t x, |
| 944 | uint32_t y, |
| 945 | uint32_t z); |
| 946 | |
| 947 | struct radv_event { |
| 948 | struct radeon_winsys_bo *bo; |
| 949 | uint64_t *map; |
| 950 | }; |
| 951 | |
| 952 | struct nir_shader; |
| 953 | |
| 954 | struct radv_shader_module { |
| 955 | struct nir_shader * nir; |
| 956 | unsigned char sha1[20]; |
| 957 | uint32_t size; |
| 958 | char data[0]; |
| 959 | }; |
| 960 | |
Bas Nieuwenhuizen | eec5578 | 2017-07-02 02:48:41 +0200 | [diff] [blame] | 961 | struct ac_shader_variant_key; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 962 | |
| 963 | void |
| 964 | radv_hash_shader(unsigned char *hash, struct radv_shader_module *module, |
| 965 | const char *entrypoint, |
| 966 | const VkSpecializationInfo *spec_info, |
| 967 | const struct radv_pipeline_layout *layout, |
Bas Nieuwenhuizen | eec5578 | 2017-07-02 02:48:41 +0200 | [diff] [blame] | 968 | const struct ac_shader_variant_key *key, |
Dave Airlie | 99936d3 | 2017-01-20 09:55:37 +1000 | [diff] [blame] | 969 | uint32_t is_geom_copy_shader); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 970 | |
| 971 | static inline gl_shader_stage |
| 972 | vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage) |
| 973 | { |
| 974 | assert(__builtin_popcount(vk_stage) == 1); |
| 975 | return ffs(vk_stage) - 1; |
| 976 | } |
| 977 | |
| 978 | static inline VkShaderStageFlagBits |
| 979 | mesa_to_vk_shader_stage(gl_shader_stage mesa_stage) |
| 980 | { |
| 981 | return (1 << mesa_stage); |
| 982 | } |
| 983 | |
| 984 | #define RADV_STAGE_MASK ((1 << MESA_SHADER_STAGES) - 1) |
| 985 | |
| 986 | #define radv_foreach_stage(stage, stage_bits) \ |
| 987 | for (gl_shader_stage stage, \ |
| 988 | __tmp = (gl_shader_stage)((stage_bits) & RADV_STAGE_MASK); \ |
| 989 | stage = __builtin_ffs(__tmp) - 1, __tmp; \ |
| 990 | __tmp &= ~(1 << (stage))) |
| 991 | |
Bas Nieuwenhuizen | c9d4b57 | 2017-03-12 22:43:51 +0100 | [diff] [blame] | 992 | |
| 993 | struct radv_shader_slab { |
| 994 | struct list_head slabs; |
| 995 | struct list_head shaders; |
| 996 | struct radeon_winsys_bo *bo; |
| 997 | uint64_t size; |
| 998 | char *ptr; |
| 999 | }; |
| 1000 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1001 | struct radv_shader_variant { |
| 1002 | uint32_t ref_count; |
| 1003 | |
| 1004 | struct radeon_winsys_bo *bo; |
Bas Nieuwenhuizen | c9d4b57 | 2017-03-12 22:43:51 +0100 | [diff] [blame] | 1005 | uint64_t bo_offset; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1006 | struct ac_shader_config config; |
| 1007 | struct ac_shader_variant_info info; |
| 1008 | unsigned rsrc1; |
| 1009 | unsigned rsrc2; |
Dave Airlie | f395e34 | 2016-11-22 04:17:49 +0000 | [diff] [blame] | 1010 | uint32_t code_size; |
Bas Nieuwenhuizen | c9d4b57 | 2017-03-12 22:43:51 +0100 | [diff] [blame] | 1011 | |
| 1012 | struct list_head slab_list; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1013 | }; |
| 1014 | |
Bas Nieuwenhuizen | c9d4b57 | 2017-03-12 22:43:51 +0100 | [diff] [blame] | 1015 | |
| 1016 | void *radv_alloc_shader_memory(struct radv_device *device, |
| 1017 | struct radv_shader_variant *shader); |
| 1018 | |
| 1019 | void radv_destroy_shader_slabs(struct radv_device *device); |
| 1020 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1021 | struct radv_depth_stencil_state { |
| 1022 | uint32_t db_depth_control; |
| 1023 | uint32_t db_stencil_control; |
| 1024 | uint32_t db_render_control; |
| 1025 | uint32_t db_render_override2; |
| 1026 | }; |
| 1027 | |
| 1028 | struct radv_blend_state { |
| 1029 | uint32_t cb_color_control; |
| 1030 | uint32_t cb_target_mask; |
Dave Airlie | 9c08010 | 2017-08-21 07:17:27 +0100 | [diff] [blame] | 1031 | uint32_t sx_mrt_blend_opt[8]; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1032 | uint32_t cb_blend_control[8]; |
| 1033 | |
| 1034 | uint32_t spi_shader_col_format; |
| 1035 | uint32_t cb_shader_mask; |
| 1036 | uint32_t db_alpha_to_mask; |
| 1037 | }; |
| 1038 | |
| 1039 | unsigned radv_format_meta_fs_key(VkFormat format); |
| 1040 | |
| 1041 | struct radv_raster_state { |
| 1042 | uint32_t pa_cl_clip_cntl; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1043 | uint32_t spi_interp_control; |
| 1044 | uint32_t pa_su_point_size; |
| 1045 | uint32_t pa_su_point_minmax; |
| 1046 | uint32_t pa_su_line_cntl; |
| 1047 | uint32_t pa_su_vtx_cntl; |
| 1048 | uint32_t pa_su_sc_mode_cntl; |
| 1049 | }; |
| 1050 | |
| 1051 | struct radv_multisample_state { |
| 1052 | uint32_t db_eqaa; |
| 1053 | uint32_t pa_sc_line_cntl; |
| 1054 | uint32_t pa_sc_mode_cntl_0; |
| 1055 | uint32_t pa_sc_mode_cntl_1; |
| 1056 | uint32_t pa_sc_aa_config; |
| 1057 | uint32_t pa_sc_aa_mask[2]; |
| 1058 | unsigned num_samples; |
| 1059 | }; |
| 1060 | |
Dave Airlie | 3360dbe | 2017-02-13 07:30:29 +0000 | [diff] [blame] | 1061 | struct radv_prim_vertex_count { |
| 1062 | uint8_t min; |
| 1063 | uint8_t incr; |
| 1064 | }; |
| 1065 | |
Dave Airlie | 4c60c68 | 2017-03-30 08:18:13 +0100 | [diff] [blame] | 1066 | struct radv_tessellation_state { |
| 1067 | uint32_t ls_hs_config; |
| 1068 | uint32_t tcs_in_layout; |
| 1069 | uint32_t tcs_out_layout; |
| 1070 | uint32_t tcs_out_offsets; |
| 1071 | uint32_t offchip_layout; |
| 1072 | unsigned num_patches; |
| 1073 | unsigned lds_size; |
| 1074 | unsigned num_tcs_input_cp; |
| 1075 | uint32_t tf_param; |
| 1076 | }; |
| 1077 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1078 | struct radv_pipeline { |
| 1079 | struct radv_device * device; |
| 1080 | uint32_t dynamic_state_mask; |
| 1081 | struct radv_dynamic_state dynamic_state; |
| 1082 | |
| 1083 | struct radv_pipeline_layout * layout; |
| 1084 | |
| 1085 | bool needs_data_cache; |
Dave Airlie | 25a5ee3 | 2017-04-18 10:21:59 +1000 | [diff] [blame] | 1086 | bool need_indirect_descriptor_sets; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1087 | struct radv_shader_variant * shaders[MESA_SHADER_STAGES]; |
Dave Airlie | 99936d3 | 2017-01-20 09:55:37 +1000 | [diff] [blame] | 1088 | struct radv_shader_variant *gs_copy_shader; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1089 | VkShaderStageFlags active_stages; |
| 1090 | |
| 1091 | uint32_t va_rsrc_word3[MAX_VERTEX_ATTRIBS]; |
| 1092 | uint32_t va_format_size[MAX_VERTEX_ATTRIBS]; |
| 1093 | uint32_t va_binding[MAX_VERTEX_ATTRIBS]; |
| 1094 | uint32_t va_offset[MAX_VERTEX_ATTRIBS]; |
| 1095 | uint32_t num_vertex_attribs; |
| 1096 | uint32_t binding_stride[MAX_VBS]; |
| 1097 | |
| 1098 | union { |
| 1099 | struct { |
| 1100 | struct radv_blend_state blend; |
| 1101 | struct radv_depth_stencil_state ds; |
| 1102 | struct radv_raster_state raster; |
| 1103 | struct radv_multisample_state ms; |
Dave Airlie | 4c60c68 | 2017-03-30 08:18:13 +0100 | [diff] [blame] | 1104 | struct radv_tessellation_state tess; |
Dave Airlie | 8996fdb | 2017-03-28 11:34:19 +1000 | [diff] [blame] | 1105 | uint32_t db_shader_control; |
Dave Airlie | 4b467c7 | 2017-03-28 11:34:46 +1000 | [diff] [blame] | 1106 | uint32_t shader_z_format; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1107 | unsigned prim; |
| 1108 | unsigned gs_out; |
Dave Airlie | cd33a5c | 2017-03-28 11:33:35 +1000 | [diff] [blame] | 1109 | uint32_t vgt_gs_mode; |
Dave Airlie | 6a68170 | 2017-06-20 13:21:04 +1000 | [diff] [blame] | 1110 | bool vgt_primitiveid_en; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1111 | bool prim_restart_enable; |
Dave Airlie | 8f41fe4 | 2017-01-20 10:21:19 +1000 | [diff] [blame] | 1112 | unsigned esgs_ring_size; |
| 1113 | unsigned gsvs_ring_size; |
Dave Airlie | 92e9c14 | 2017-03-28 11:43:48 +1000 | [diff] [blame] | 1114 | uint32_t ps_input_cntl[32]; |
| 1115 | uint32_t ps_input_cntl_num; |
Dave Airlie | 0232ea8 | 2017-03-28 11:48:38 +1000 | [diff] [blame] | 1116 | uint32_t pa_cl_vs_out_cntl; |
Dave Airlie | 239a922 | 2017-03-28 12:59:17 +1000 | [diff] [blame] | 1117 | uint32_t vgt_shader_stages_en; |
Dave Airlie | 734ea16 | 2017-06-07 09:04:30 +1000 | [diff] [blame] | 1118 | uint32_t vtx_base_sgpr; |
| 1119 | uint8_t vtx_emit_num; |
Dave Airlie | 3360dbe | 2017-02-13 07:30:29 +0000 | [diff] [blame] | 1120 | struct radv_prim_vertex_count prim_vertex_count; |
Bas Nieuwenhuizen | 8a53e6e4 | 2017-03-29 22:58:10 +0200 | [diff] [blame] | 1121 | bool can_use_guardband; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1122 | } graphics; |
| 1123 | }; |
Bas Nieuwenhuizen | ccff93e | 2017-01-29 15:20:03 +0100 | [diff] [blame] | 1124 | |
| 1125 | unsigned max_waves; |
| 1126 | unsigned scratch_bytes_per_wave; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1127 | }; |
| 1128 | |
Dave Airlie | f26fa87 | 2017-01-18 13:50:16 +1000 | [diff] [blame] | 1129 | static inline bool radv_pipeline_has_gs(struct radv_pipeline *pipeline) |
| 1130 | { |
| 1131 | return pipeline->shaders[MESA_SHADER_GEOMETRY] ? true : false; |
| 1132 | } |
| 1133 | |
Dave Airlie | 0604284 | 2017-03-30 07:44:20 +0100 | [diff] [blame] | 1134 | static inline bool radv_pipeline_has_tess(struct radv_pipeline *pipeline) |
| 1135 | { |
| 1136 | return pipeline->shaders[MESA_SHADER_TESS_EVAL] ? true : false; |
| 1137 | } |
| 1138 | |
Dave Airlie | 3f48021 | 2017-06-07 09:01:38 +1000 | [diff] [blame] | 1139 | uint32_t radv_shader_stage_to_user_data_0(gl_shader_stage stage, bool has_gs, bool has_tess); |
| 1140 | struct ac_userdata_info *radv_lookup_user_sgpr(struct radv_pipeline *pipeline, |
| 1141 | gl_shader_stage stage, |
| 1142 | int idx); |
| 1143 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1144 | struct radv_graphics_pipeline_create_info { |
| 1145 | bool use_rectlist; |
| 1146 | bool db_depth_clear; |
| 1147 | bool db_stencil_clear; |
| 1148 | bool db_depth_disable_expclear; |
| 1149 | bool db_stencil_disable_expclear; |
| 1150 | bool db_flush_depth_inplace; |
| 1151 | bool db_flush_stencil_inplace; |
| 1152 | bool db_resummarize; |
| 1153 | uint32_t custom_blend_mode; |
| 1154 | }; |
| 1155 | |
| 1156 | VkResult |
| 1157 | radv_pipeline_init(struct radv_pipeline *pipeline, struct radv_device *device, |
| 1158 | struct radv_pipeline_cache *cache, |
| 1159 | const VkGraphicsPipelineCreateInfo *pCreateInfo, |
| 1160 | const struct radv_graphics_pipeline_create_info *extra, |
| 1161 | const VkAllocationCallbacks *alloc); |
| 1162 | |
| 1163 | VkResult |
| 1164 | radv_graphics_pipeline_create(VkDevice device, |
| 1165 | VkPipelineCache cache, |
| 1166 | const VkGraphicsPipelineCreateInfo *pCreateInfo, |
| 1167 | const struct radv_graphics_pipeline_create_info *extra, |
| 1168 | const VkAllocationCallbacks *alloc, |
| 1169 | VkPipeline *pPipeline); |
| 1170 | |
| 1171 | struct vk_format_description; |
| 1172 | uint32_t radv_translate_buffer_dataformat(const struct vk_format_description *desc, |
| 1173 | int first_non_void); |
| 1174 | uint32_t radv_translate_buffer_numformat(const struct vk_format_description *desc, |
| 1175 | int first_non_void); |
| 1176 | uint32_t radv_translate_colorformat(VkFormat format); |
| 1177 | uint32_t radv_translate_color_numformat(VkFormat format, |
| 1178 | const struct vk_format_description *desc, |
| 1179 | int first_non_void); |
| 1180 | uint32_t radv_colorformat_endian_swap(uint32_t colorformat); |
| 1181 | unsigned radv_translate_colorswap(VkFormat format, bool do_endian_swap); |
| 1182 | uint32_t radv_translate_dbformat(VkFormat format); |
| 1183 | uint32_t radv_translate_tex_dataformat(VkFormat format, |
| 1184 | const struct vk_format_description *desc, |
| 1185 | int first_non_void); |
| 1186 | uint32_t radv_translate_tex_numformat(VkFormat format, |
| 1187 | const struct vk_format_description *desc, |
| 1188 | int first_non_void); |
| 1189 | bool radv_format_pack_clear_color(VkFormat format, |
| 1190 | uint32_t clear_vals[2], |
| 1191 | VkClearColorValue *value); |
| 1192 | bool radv_is_colorbuffer_format_supported(VkFormat format, bool *blendable); |
| 1193 | |
| 1194 | struct radv_fmask_info { |
| 1195 | uint64_t offset; |
| 1196 | uint64_t size; |
| 1197 | unsigned alignment; |
| 1198 | unsigned pitch_in_pixels; |
| 1199 | unsigned bank_height; |
| 1200 | unsigned slice_tile_max; |
| 1201 | unsigned tile_mode_index; |
Dave Airlie | 1e696b9 | 2017-08-04 06:54:15 +0100 | [diff] [blame] | 1202 | unsigned tile_swizzle; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1203 | }; |
| 1204 | |
| 1205 | struct radv_cmask_info { |
| 1206 | uint64_t offset; |
| 1207 | uint64_t size; |
| 1208 | unsigned alignment; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1209 | unsigned slice_tile_max; |
| 1210 | unsigned base_address_reg; |
| 1211 | }; |
| 1212 | |
| 1213 | struct r600_htile_info { |
| 1214 | uint64_t offset; |
| 1215 | uint64_t size; |
| 1216 | unsigned pitch; |
| 1217 | unsigned height; |
| 1218 | unsigned xalign; |
| 1219 | unsigned yalign; |
| 1220 | }; |
| 1221 | |
| 1222 | struct radv_image { |
| 1223 | VkImageType type; |
| 1224 | /* The original VkFormat provided by the client. This may not match any |
| 1225 | * of the actual surface formats. |
| 1226 | */ |
| 1227 | VkFormat vk_format; |
| 1228 | VkImageAspectFlags aspects; |
Nicolai Hähnle | dfc06d2 | 2017-05-10 23:01:00 +0200 | [diff] [blame] | 1229 | struct ac_surf_info info; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1230 | VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */ |
| 1231 | VkImageTiling tiling; /** VkImageCreateInfo::tiling */ |
Bas Nieuwenhuizen | 6154efc | 2017-02-04 15:56:20 +0100 | [diff] [blame] | 1232 | VkImageCreateFlags flags; /** VkImageCreateInfo::flags */ |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1233 | |
| 1234 | VkDeviceSize size; |
| 1235 | uint32_t alignment; |
| 1236 | |
Bas Nieuwenhuizen | accc5fc | 2016-12-17 21:25:32 +0100 | [diff] [blame] | 1237 | bool exclusive; |
| 1238 | unsigned queue_family_mask; |
| 1239 | |
Jason Ekstrand | b708297 | 2017-07-15 02:08:01 +0200 | [diff] [blame] | 1240 | bool shareable; |
| 1241 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1242 | /* Set when bound */ |
| 1243 | struct radeon_winsys_bo *bo; |
| 1244 | VkDeviceSize offset; |
| 1245 | uint32_t dcc_offset; |
Bas Nieuwenhuizen | 3b455c1 | 2017-03-07 00:58:04 +0100 | [diff] [blame] | 1246 | uint32_t htile_offset; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1247 | struct radeon_surf surface; |
| 1248 | |
| 1249 | struct radv_fmask_info fmask; |
| 1250 | struct radv_cmask_info cmask; |
| 1251 | uint32_t clear_value_offset; |
Dave Airlie | 9ee6746 | 2017-03-02 21:39:10 +0000 | [diff] [blame] | 1252 | uint32_t dcc_pred_offset; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1253 | }; |
| 1254 | |
Bas Nieuwenhuizen | 0628580 | 2017-05-15 01:23:24 +0200 | [diff] [blame] | 1255 | /* Whether the image has a htile that is known consistent with the contents of |
| 1256 | * the image. */ |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1257 | bool radv_layout_has_htile(const struct radv_image *image, |
Bas Nieuwenhuizen | 0b26f0e | 2017-05-15 23:00:17 +0200 | [diff] [blame] | 1258 | VkImageLayout layout, |
| 1259 | unsigned queue_mask); |
Bas Nieuwenhuizen | 0628580 | 2017-05-15 01:23:24 +0200 | [diff] [blame] | 1260 | |
| 1261 | /* Whether the image has a htile that is known consistent with the contents of |
| 1262 | * the image and is allowed to be in compressed form. |
| 1263 | * |
| 1264 | * If this is false reads that don't use the htile should be able to return |
| 1265 | * correct results. |
| 1266 | */ |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1267 | bool radv_layout_is_htile_compressed(const struct radv_image *image, |
Bas Nieuwenhuizen | 0b26f0e | 2017-05-15 23:00:17 +0200 | [diff] [blame] | 1268 | VkImageLayout layout, |
| 1269 | unsigned queue_mask); |
Bas Nieuwenhuizen | 0628580 | 2017-05-15 01:23:24 +0200 | [diff] [blame] | 1270 | |
Bas Nieuwenhuizen | 059af25 | 2016-12-27 00:57:36 +0100 | [diff] [blame] | 1271 | bool radv_layout_can_fast_clear(const struct radv_image *image, |
| 1272 | VkImageLayout layout, |
| 1273 | unsigned queue_mask); |
Bas Nieuwenhuizen | accc5fc | 2016-12-17 21:25:32 +0100 | [diff] [blame] | 1274 | |
| 1275 | |
Dave Airlie | cda9f3d | 2017-01-31 15:18:33 +1000 | [diff] [blame] | 1276 | unsigned radv_image_queue_family_mask(const struct radv_image *image, uint32_t family, uint32_t queue_family); |
Bas Nieuwenhuizen | accc5fc | 2016-12-17 21:25:32 +0100 | [diff] [blame] | 1277 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1278 | static inline uint32_t |
| 1279 | radv_get_layerCount(const struct radv_image *image, |
| 1280 | const VkImageSubresourceRange *range) |
| 1281 | { |
| 1282 | return range->layerCount == VK_REMAINING_ARRAY_LAYERS ? |
Dave Airlie | 7e8d0a4 | 2017-05-02 09:49:14 +1000 | [diff] [blame] | 1283 | image->info.array_size - range->baseArrayLayer : range->layerCount; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1284 | } |
| 1285 | |
| 1286 | static inline uint32_t |
| 1287 | radv_get_levelCount(const struct radv_image *image, |
| 1288 | const VkImageSubresourceRange *range) |
| 1289 | { |
| 1290 | return range->levelCount == VK_REMAINING_MIP_LEVELS ? |
Dave Airlie | 7e8d0a4 | 2017-05-02 09:49:14 +1000 | [diff] [blame] | 1291 | image->info.levels - range->baseMipLevel : range->levelCount; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1292 | } |
| 1293 | |
| 1294 | struct radeon_bo_metadata; |
| 1295 | void |
| 1296 | radv_init_metadata(struct radv_device *device, |
| 1297 | struct radv_image *image, |
| 1298 | struct radeon_bo_metadata *metadata); |
| 1299 | |
| 1300 | struct radv_image_view { |
| 1301 | struct radv_image *image; /**< VkImageViewCreateInfo::image */ |
| 1302 | struct radeon_winsys_bo *bo; |
| 1303 | |
| 1304 | VkImageViewType type; |
| 1305 | VkImageAspectFlags aspect_mask; |
| 1306 | VkFormat vk_format; |
| 1307 | uint32_t base_layer; |
| 1308 | uint32_t layer_count; |
| 1309 | uint32_t base_mip; |
Dave Airlie | 5378b5d | 2017-08-21 13:56:33 +1000 | [diff] [blame] | 1310 | uint32_t level_count; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1311 | VkExtent3D extent; /**< Extent of VkImageViewCreateInfo::baseMipLevel. */ |
| 1312 | |
| 1313 | uint32_t descriptor[8]; |
| 1314 | uint32_t fmask_descriptor[8]; |
Alex Smith | 0e1886e | 2017-07-12 10:29:52 +0100 | [diff] [blame] | 1315 | |
| 1316 | /* Descriptor for use as a storage image as opposed to a sampled image. |
| 1317 | * This has a few differences for cube maps (e.g. type). |
| 1318 | */ |
| 1319 | uint32_t storage_descriptor[8]; |
| 1320 | uint32_t storage_fmask_descriptor[8]; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1321 | }; |
| 1322 | |
| 1323 | struct radv_image_create_info { |
| 1324 | const VkImageCreateInfo *vk_info; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1325 | bool scanout; |
| 1326 | }; |
| 1327 | |
| 1328 | VkResult radv_image_create(VkDevice _device, |
| 1329 | const struct radv_image_create_info *info, |
| 1330 | const VkAllocationCallbacks* alloc, |
| 1331 | VkImage *pImage); |
| 1332 | |
| 1333 | void radv_image_view_init(struct radv_image_view *view, |
| 1334 | struct radv_device *device, |
Bas Nieuwenhuizen | 78bef01 | 2017-06-25 22:25:47 +0200 | [diff] [blame] | 1335 | const VkImageViewCreateInfo* pCreateInfo); |
Dave Airlie | 823e9ea | 2017-04-28 08:06:09 +0100 | [diff] [blame] | 1336 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1337 | struct radv_buffer_view { |
| 1338 | struct radeon_winsys_bo *bo; |
| 1339 | VkFormat vk_format; |
| 1340 | uint64_t range; /**< VkBufferViewCreateInfo::range */ |
| 1341 | uint32_t state[4]; |
| 1342 | }; |
| 1343 | void radv_buffer_view_init(struct radv_buffer_view *view, |
| 1344 | struct radv_device *device, |
| 1345 | const VkBufferViewCreateInfo* pCreateInfo, |
| 1346 | struct radv_cmd_buffer *cmd_buffer); |
| 1347 | |
| 1348 | static inline struct VkExtent3D |
| 1349 | radv_sanitize_image_extent(const VkImageType imageType, |
| 1350 | const struct VkExtent3D imageExtent) |
| 1351 | { |
| 1352 | switch (imageType) { |
| 1353 | case VK_IMAGE_TYPE_1D: |
| 1354 | return (VkExtent3D) { imageExtent.width, 1, 1 }; |
| 1355 | case VK_IMAGE_TYPE_2D: |
| 1356 | return (VkExtent3D) { imageExtent.width, imageExtent.height, 1 }; |
| 1357 | case VK_IMAGE_TYPE_3D: |
| 1358 | return imageExtent; |
| 1359 | default: |
| 1360 | unreachable("invalid image type"); |
| 1361 | } |
| 1362 | } |
| 1363 | |
| 1364 | static inline struct VkOffset3D |
| 1365 | radv_sanitize_image_offset(const VkImageType imageType, |
| 1366 | const struct VkOffset3D imageOffset) |
| 1367 | { |
| 1368 | switch (imageType) { |
| 1369 | case VK_IMAGE_TYPE_1D: |
| 1370 | return (VkOffset3D) { imageOffset.x, 0, 0 }; |
| 1371 | case VK_IMAGE_TYPE_2D: |
| 1372 | return (VkOffset3D) { imageOffset.x, imageOffset.y, 0 }; |
| 1373 | case VK_IMAGE_TYPE_3D: |
| 1374 | return imageOffset; |
| 1375 | default: |
| 1376 | unreachable("invalid image type"); |
| 1377 | } |
| 1378 | } |
| 1379 | |
Dave Airlie | d5400a5 | 2017-05-02 09:40:36 +1000 | [diff] [blame] | 1380 | static inline bool |
| 1381 | radv_image_extent_compare(const struct radv_image *image, |
| 1382 | const VkExtent3D *extent) |
| 1383 | { |
Dave Airlie | 7e8d0a4 | 2017-05-02 09:49:14 +1000 | [diff] [blame] | 1384 | if (extent->width != image->info.width || |
| 1385 | extent->height != image->info.height || |
| 1386 | extent->depth != image->info.depth) |
Dave Airlie | d5400a5 | 2017-05-02 09:40:36 +1000 | [diff] [blame] | 1387 | return false; |
| 1388 | return true; |
| 1389 | } |
| 1390 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1391 | struct radv_sampler { |
| 1392 | uint32_t state[4]; |
| 1393 | }; |
| 1394 | |
| 1395 | struct radv_color_buffer_info { |
Dave Airlie | 745aa17 | 2017-06-01 05:32:25 +0100 | [diff] [blame] | 1396 | uint64_t cb_color_base; |
| 1397 | uint64_t cb_color_cmask; |
| 1398 | uint64_t cb_color_fmask; |
| 1399 | uint64_t cb_dcc_base; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1400 | uint32_t cb_color_pitch; |
| 1401 | uint32_t cb_color_slice; |
| 1402 | uint32_t cb_color_view; |
| 1403 | uint32_t cb_color_info; |
| 1404 | uint32_t cb_color_attrib; |
Dave Airlie | ac3e189 | 2017-06-06 08:38:36 +1000 | [diff] [blame] | 1405 | uint32_t cb_color_attrib2; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1406 | uint32_t cb_dcc_control; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1407 | uint32_t cb_color_cmask_slice; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1408 | uint32_t cb_color_fmask_slice; |
| 1409 | uint32_t cb_clear_value0; |
| 1410 | uint32_t cb_clear_value1; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1411 | uint32_t micro_tile_mode; |
Dave Airlie | ac3e189 | 2017-06-06 08:38:36 +1000 | [diff] [blame] | 1412 | uint32_t gfx9_epitch; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1413 | }; |
| 1414 | |
| 1415 | struct radv_ds_buffer_info { |
Dave Airlie | 745aa17 | 2017-06-01 05:32:25 +0100 | [diff] [blame] | 1416 | uint64_t db_z_read_base; |
| 1417 | uint64_t db_stencil_read_base; |
| 1418 | uint64_t db_z_write_base; |
| 1419 | uint64_t db_stencil_write_base; |
| 1420 | uint64_t db_htile_data_base; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1421 | uint32_t db_depth_info; |
| 1422 | uint32_t db_z_info; |
| 1423 | uint32_t db_stencil_info; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1424 | uint32_t db_depth_view; |
| 1425 | uint32_t db_depth_size; |
| 1426 | uint32_t db_depth_slice; |
| 1427 | uint32_t db_htile_surface; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1428 | uint32_t pa_su_poly_offset_db_fmt_cntl; |
Dave Airlie | 41eba75 | 2017-06-06 08:39:44 +1000 | [diff] [blame] | 1429 | uint32_t db_z_info2; |
| 1430 | uint32_t db_stencil_info2; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1431 | float offset_scale; |
| 1432 | }; |
| 1433 | |
| 1434 | struct radv_attachment_info { |
| 1435 | union { |
| 1436 | struct radv_color_buffer_info cb; |
| 1437 | struct radv_ds_buffer_info ds; |
| 1438 | }; |
| 1439 | struct radv_image_view *attachment; |
| 1440 | }; |
| 1441 | |
| 1442 | struct radv_framebuffer { |
| 1443 | uint32_t width; |
| 1444 | uint32_t height; |
| 1445 | uint32_t layers; |
| 1446 | |
| 1447 | uint32_t attachment_count; |
| 1448 | struct radv_attachment_info attachments[0]; |
| 1449 | }; |
| 1450 | |
| 1451 | struct radv_subpass_barrier { |
| 1452 | VkPipelineStageFlags src_stage_mask; |
| 1453 | VkAccessFlags src_access_mask; |
| 1454 | VkAccessFlags dst_access_mask; |
| 1455 | }; |
| 1456 | |
| 1457 | struct radv_subpass { |
| 1458 | uint32_t input_count; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1459 | uint32_t color_count; |
Dave Airlie | ce0f692 | 2017-05-02 10:32:02 +1000 | [diff] [blame] | 1460 | VkAttachmentReference * input_attachments; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1461 | VkAttachmentReference * color_attachments; |
| 1462 | VkAttachmentReference * resolve_attachments; |
| 1463 | VkAttachmentReference depth_stencil_attachment; |
| 1464 | |
| 1465 | /** Subpass has at least one resolve attachment */ |
| 1466 | bool has_resolve; |
| 1467 | |
| 1468 | struct radv_subpass_barrier start_barrier; |
Bas Nieuwenhuizen | 3907d63 | 2017-07-02 19:20:47 +0200 | [diff] [blame] | 1469 | |
| 1470 | uint32_t view_mask; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1471 | }; |
| 1472 | |
| 1473 | struct radv_render_pass_attachment { |
| 1474 | VkFormat format; |
| 1475 | uint32_t samples; |
| 1476 | VkAttachmentLoadOp load_op; |
| 1477 | VkAttachmentLoadOp stencil_load_op; |
| 1478 | VkImageLayout initial_layout; |
| 1479 | VkImageLayout final_layout; |
Bas Nieuwenhuizen | 3907d63 | 2017-07-02 19:20:47 +0200 | [diff] [blame] | 1480 | uint32_t view_mask; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1481 | }; |
| 1482 | |
| 1483 | struct radv_render_pass { |
| 1484 | uint32_t attachment_count; |
| 1485 | uint32_t subpass_count; |
| 1486 | VkAttachmentReference * subpass_attachments; |
| 1487 | struct radv_render_pass_attachment * attachments; |
| 1488 | struct radv_subpass_barrier end_barrier; |
| 1489 | struct radv_subpass subpasses[0]; |
| 1490 | }; |
| 1491 | |
| 1492 | VkResult radv_device_init_meta(struct radv_device *device); |
| 1493 | void radv_device_finish_meta(struct radv_device *device); |
| 1494 | |
| 1495 | struct radv_query_pool { |
| 1496 | struct radeon_winsys_bo *bo; |
| 1497 | uint32_t stride; |
| 1498 | uint32_t availability_offset; |
| 1499 | char *ptr; |
| 1500 | VkQueryType type; |
Bas Nieuwenhuizen | 8475a14 | 2017-04-10 22:20:19 +0200 | [diff] [blame] | 1501 | uint32_t pipeline_stats_mask; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1502 | }; |
| 1503 | |
Dave Airlie | eaa56ea | 2017-02-27 19:14:00 +0000 | [diff] [blame] | 1504 | struct radv_semaphore { |
| 1505 | /* use a winsys sem for non-exportable */ |
| 1506 | struct radeon_winsys_sem *sem; |
| 1507 | uint32_t syncobj; |
| 1508 | uint32_t temp_syncobj; |
| 1509 | }; |
| 1510 | |
| 1511 | VkResult radv_alloc_sem_info(struct radv_winsys_sem_info *sem_info, |
| 1512 | int num_wait_sems, |
| 1513 | const VkSemaphore *wait_sems, |
| 1514 | int num_signal_sems, |
| 1515 | const VkSemaphore *signal_sems); |
| 1516 | void radv_free_sem_info(struct radv_winsys_sem_info *sem_info); |
| 1517 | |
Fredrik Höglund | a6e94a8 | 2017-03-29 18:08:06 +0200 | [diff] [blame] | 1518 | void |
| 1519 | radv_update_descriptor_sets(struct radv_device *device, |
| 1520 | struct radv_cmd_buffer *cmd_buffer, |
| 1521 | VkDescriptorSet overrideSet, |
| 1522 | uint32_t descriptorWriteCount, |
| 1523 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 1524 | uint32_t descriptorCopyCount, |
| 1525 | const VkCopyDescriptorSet *pDescriptorCopies); |
| 1526 | |
Fredrik Höglund | c1f8c83 | 2017-03-29 19:19:47 +0200 | [diff] [blame] | 1527 | void |
| 1528 | radv_update_descriptor_set_with_template(struct radv_device *device, |
| 1529 | struct radv_cmd_buffer *cmd_buffer, |
| 1530 | struct radv_descriptor_set *set, |
| 1531 | VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, |
| 1532 | const void *pData); |
| 1533 | |
Fredrik Höglund | f95caae | 2017-04-14 00:26:58 +0200 | [diff] [blame] | 1534 | void radv_meta_push_descriptor_set(struct radv_cmd_buffer *cmd_buffer, |
| 1535 | VkPipelineBindPoint pipelineBindPoint, |
| 1536 | VkPipelineLayout _layout, |
| 1537 | uint32_t set, |
| 1538 | uint32_t descriptorWriteCount, |
| 1539 | const VkWriteDescriptorSet *pDescriptorWrites); |
| 1540 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1541 | void radv_initialise_cmask(struct radv_cmd_buffer *cmd_buffer, |
| 1542 | struct radv_image *image, uint32_t value); |
| 1543 | void radv_initialize_dcc(struct radv_cmd_buffer *cmd_buffer, |
| 1544 | struct radv_image *image, uint32_t value); |
Fredrik Höglund | 0a153f4 | 2016-10-25 20:31:41 +0200 | [diff] [blame] | 1545 | |
| 1546 | struct radv_fence { |
| 1547 | struct radeon_winsys_fence *fence; |
| 1548 | bool submitted; |
| 1549 | bool signalled; |
| 1550 | }; |
| 1551 | |
Grazvydas Ignotas | 5458b02 | 2017-03-05 23:04:50 +0200 | [diff] [blame] | 1552 | struct radeon_winsys_sem; |
| 1553 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1554 | #define RADV_DEFINE_HANDLE_CASTS(__radv_type, __VkType) \ |
| 1555 | \ |
| 1556 | static inline struct __radv_type * \ |
| 1557 | __radv_type ## _from_handle(__VkType _handle) \ |
| 1558 | { \ |
| 1559 | return (struct __radv_type *) _handle; \ |
| 1560 | } \ |
| 1561 | \ |
| 1562 | static inline __VkType \ |
| 1563 | __radv_type ## _to_handle(struct __radv_type *_obj) \ |
| 1564 | { \ |
| 1565 | return (__VkType) _obj; \ |
| 1566 | } |
| 1567 | |
| 1568 | #define RADV_DEFINE_NONDISP_HANDLE_CASTS(__radv_type, __VkType) \ |
| 1569 | \ |
| 1570 | static inline struct __radv_type * \ |
| 1571 | __radv_type ## _from_handle(__VkType _handle) \ |
| 1572 | { \ |
| 1573 | return (struct __radv_type *)(uintptr_t) _handle; \ |
| 1574 | } \ |
| 1575 | \ |
| 1576 | static inline __VkType \ |
| 1577 | __radv_type ## _to_handle(struct __radv_type *_obj) \ |
| 1578 | { \ |
| 1579 | return (__VkType)(uintptr_t) _obj; \ |
| 1580 | } |
| 1581 | |
| 1582 | #define RADV_FROM_HANDLE(__radv_type, __name, __handle) \ |
| 1583 | struct __radv_type *__name = __radv_type ## _from_handle(__handle) |
| 1584 | |
| 1585 | RADV_DEFINE_HANDLE_CASTS(radv_cmd_buffer, VkCommandBuffer) |
| 1586 | RADV_DEFINE_HANDLE_CASTS(radv_device, VkDevice) |
| 1587 | RADV_DEFINE_HANDLE_CASTS(radv_instance, VkInstance) |
| 1588 | RADV_DEFINE_HANDLE_CASTS(radv_physical_device, VkPhysicalDevice) |
| 1589 | RADV_DEFINE_HANDLE_CASTS(radv_queue, VkQueue) |
| 1590 | |
| 1591 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_cmd_pool, VkCommandPool) |
| 1592 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_buffer, VkBuffer) |
| 1593 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_buffer_view, VkBufferView) |
| 1594 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_pool, VkDescriptorPool) |
| 1595 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_set, VkDescriptorSet) |
| 1596 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_set_layout, VkDescriptorSetLayout) |
Fredrik Höglund | c1f8c83 | 2017-03-29 19:19:47 +0200 | [diff] [blame] | 1597 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_descriptor_update_template, VkDescriptorUpdateTemplateKHR) |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1598 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_device_memory, VkDeviceMemory) |
| 1599 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_fence, VkFence) |
| 1600 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_event, VkEvent) |
| 1601 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_framebuffer, VkFramebuffer) |
| 1602 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_image, VkImage) |
| 1603 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_image_view, VkImageView); |
| 1604 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline_cache, VkPipelineCache) |
| 1605 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline, VkPipeline) |
| 1606 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_pipeline_layout, VkPipelineLayout) |
| 1607 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_query_pool, VkQueryPool) |
| 1608 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_render_pass, VkRenderPass) |
| 1609 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_sampler, VkSampler) |
| 1610 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_shader_module, VkShaderModule) |
Dave Airlie | eaa56ea | 2017-02-27 19:14:00 +0000 | [diff] [blame] | 1611 | RADV_DEFINE_NONDISP_HANDLE_CASTS(radv_semaphore, VkSemaphore) |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 1612 | |
Edward O'Callaghan | ba43768 | 2016-10-07 22:19:19 +1100 | [diff] [blame] | 1613 | #endif /* RADV_PRIVATE_H */ |