Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/panfrost/vulkan/panvk_private.h
4560 views
1
/*
2
* Copyright © 2021 Collabora Ltd.
3
*
4
* derived from tu_private.h driver which is:
5
* Copyright © 2016 Red Hat.
6
* Copyright © 2016 Bas Nieuwenhuizen
7
* Copyright © 2015 Intel Corporation
8
*
9
* Permission is hereby granted, free of charge, to any person obtaining a
10
* copy of this software and associated documentation files (the "Software"),
11
* to deal in the Software without restriction, including without limitation
12
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
13
* and/or sell copies of the Software, and to permit persons to whom the
14
* Software is furnished to do so, subject to the following conditions:
15
*
16
* The above copyright notice and this permission notice (including the next
17
* paragraph) shall be included in all copies or substantial portions of the
18
* Software.
19
*
20
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26
* DEALINGS IN THE SOFTWARE.
27
*/
28
29
#ifndef PANVK_PRIVATE_H
30
#define PANVK_PRIVATE_H
31
32
#include <assert.h>
33
#include <pthread.h>
34
#include <stdbool.h>
35
#include <stdint.h>
36
#include <stdio.h>
37
#include <stdlib.h>
38
#include <string.h>
39
#ifdef HAVE_VALGRIND
40
#include <memcheck.h>
41
#include <valgrind.h>
42
#define VG(x) x
43
#else
44
#define VG(x)
45
#endif
46
47
#include "c11/threads.h"
48
#include "compiler/shader_enums.h"
49
#include "util/list.h"
50
#include "util/macros.h"
51
#include "vk_alloc.h"
52
#include "vk_device.h"
53
#include "vk_instance.h"
54
#include "vk_object.h"
55
#include "vk_physical_device.h"
56
#include "wsi_common.h"
57
58
#include "drm-uapi/panfrost_drm.h"
59
60
#include "midgard/midgard_compile.h"
61
62
#include "pan_blend.h"
63
#include "pan_blitter.h"
64
#include "pan_cs.h"
65
#include "pan_device.h"
66
#include "panvk_mempool.h"
67
#include "pan_texture.h"
68
#include "pan_scoreboard.h"
69
#include "pan_shader.h"
70
#include "vk_extensions.h"
71
#include "panvk_varyings.h"
72
73
/* Pre-declarations needed for WSI entrypoints */
74
struct wl_surface;
75
struct wl_display;
76
typedef struct xcb_connection_t xcb_connection_t;
77
typedef uint32_t xcb_visualid_t;
78
typedef uint32_t xcb_window_t;
79
80
#include <vulkan/vk_android_native_buffer.h>
81
#include <vulkan/vk_icd.h>
82
#include <vulkan/vulkan.h>
83
84
#include "panvk_entrypoints.h"
85
86
#define MAX_BIND_POINTS 2 /* compute + graphics */
87
#define MAX_VBS 16
88
#define MAX_VERTEX_ATTRIBS 16
89
#define MAX_RTS 8
90
#define MAX_VSC_PIPES 32
91
#define MAX_VIEWPORTS 1
92
#define MAX_SCISSORS 16
93
#define MAX_DISCARD_RECTANGLES 4
94
#define MAX_PUSH_CONSTANTS_SIZE 128
95
#define MAX_PUSH_DESCRIPTORS 32
96
#define MAX_DYNAMIC_UNIFORM_BUFFERS 16
97
#define MAX_DYNAMIC_STORAGE_BUFFERS 8
98
#define MAX_DYNAMIC_BUFFERS \
99
(MAX_DYNAMIC_UNIFORM_BUFFERS + MAX_DYNAMIC_STORAGE_BUFFERS)
100
#define MAX_SAMPLES_LOG2 4
101
#define NUM_META_FS_KEYS 13
102
#define PANVK_MAX_DRM_DEVICES 1
103
#define MAX_VIEWS 8
104
105
#define NUM_DEPTH_CLEAR_PIPELINES 3
106
107
#define panvk_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
108
109
/* Whenever we generate an error, pass it through this function. Useful for
110
* debugging, where we can break on it. Only call at error site, not when
111
* propagating errors. Might be useful to plug in a stack trace here.
112
*/
113
114
struct panvk_instance;
115
116
VkResult
117
__vk_errorf(struct panvk_instance *instance,
118
VkResult error,
119
const char *file,
120
int line,
121
const char *format,
122
...);
123
124
#define vk_error(instance, error) \
125
__vk_errorf(instance, error, __FILE__, __LINE__, NULL);
126
#define vk_errorf(instance, error, format, ...) \
127
__vk_errorf(instance, error, __FILE__, __LINE__, format, ##__VA_ARGS__);
128
129
void
130
panvk_logi(const char *format, ...) panvk_printflike(1, 2);
131
void
132
panvk_logi_v(const char *format, va_list va);
133
134
#define panvk_stub() assert(!"stub")
135
136
struct panvk_meta {
137
struct panvk_pool bin_pool;
138
struct panvk_pool desc_pool;
139
140
/* Access to the blitter pools are protected by the blitter
141
* shader/rsd locks. They can't be merged with other binary/desc
142
* pools unless we patch pan_blitter.c to external pool locks.
143
*/
144
struct {
145
struct panvk_pool bin_pool;
146
struct panvk_pool desc_pool;
147
} blitter;
148
};
149
150
struct panvk_physical_device {
151
struct vk_physical_device vk;
152
153
/* The API agnostic device object. */
154
struct panfrost_device pdev;
155
156
struct panvk_instance *instance;
157
158
char path[20];
159
char name[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE];
160
uint8_t driver_uuid[VK_UUID_SIZE];
161
uint8_t device_uuid[VK_UUID_SIZE];
162
uint8_t cache_uuid[VK_UUID_SIZE];
163
164
struct wsi_device wsi_device;
165
struct panvk_meta meta;
166
167
int master_fd;
168
};
169
170
void
171
panvk_meta_init(struct panvk_physical_device *dev);
172
173
void
174
panvk_meta_cleanup(struct panvk_physical_device *dev);
175
176
177
enum panvk_debug_flags {
178
PANVK_DEBUG_STARTUP = 1 << 0,
179
PANVK_DEBUG_NIR = 1 << 1,
180
PANVK_DEBUG_TRACE = 1 << 2,
181
PANVK_DEBUG_SYNC = 1 << 3,
182
PANVK_DEBUG_AFBC = 1 << 4,
183
PANVK_DEBUG_LINEAR = 1 << 5,
184
};
185
186
struct panvk_instance {
187
struct vk_instance vk;
188
189
uint32_t api_version;
190
int physical_device_count;
191
struct panvk_physical_device physical_devices[PANVK_MAX_DRM_DEVICES];
192
193
enum panvk_debug_flags debug_flags;
194
};
195
196
VkResult
197
panvk_wsi_init(struct panvk_physical_device *physical_device);
198
void
199
panvk_wsi_finish(struct panvk_physical_device *physical_device);
200
201
bool
202
panvk_instance_extension_supported(const char *name);
203
uint32_t
204
panvk_physical_device_api_version(struct panvk_physical_device *dev);
205
bool
206
panvk_physical_device_extension_supported(struct panvk_physical_device *dev,
207
const char *name);
208
209
struct panvk_pipeline_cache {
210
struct vk_object_base base;
211
VkAllocationCallbacks alloc;
212
};
213
214
/* queue types */
215
#define PANVK_QUEUE_GENERAL 0
216
217
#define PANVK_MAX_QUEUE_FAMILIES 1
218
219
struct panvk_queue {
220
struct vk_object_base base;
221
struct panvk_device *device;
222
uint32_t queue_family_index;
223
VkDeviceQueueCreateFlags flags;
224
uint32_t sync;
225
};
226
227
struct panvk_device {
228
struct vk_device vk;
229
230
struct panvk_instance *instance;
231
232
struct panvk_queue *queues[PANVK_MAX_QUEUE_FAMILIES];
233
int queue_count[PANVK_MAX_QUEUE_FAMILIES];
234
235
struct panvk_physical_device *physical_device;
236
int _lost;
237
};
238
239
VkResult _panvk_device_set_lost(struct panvk_device *device,
240
const char *file, int line,
241
const char *msg, ...) PRINTFLIKE(4, 5);
242
#define panvk_device_set_lost(dev, ...) \
243
_panvk_device_set_lost(dev, __FILE__, __LINE__, __VA_ARGS__)
244
245
static inline bool
246
panvk_device_is_lost(struct panvk_device *device)
247
{
248
return unlikely(p_atomic_read(&device->_lost));
249
}
250
251
struct panvk_batch {
252
struct list_head node;
253
struct util_dynarray jobs;
254
struct util_dynarray event_ops;
255
struct pan_scoreboard scoreboard;
256
struct {
257
const struct panvk_framebuffer *info;
258
struct panfrost_ptr desc;
259
} fb;
260
struct {
261
struct panfrost_bo *src, *dst;
262
} blit;
263
struct panfrost_ptr tls;
264
mali_ptr fragment_job;
265
struct {
266
struct pan_tiler_context ctx;
267
struct panfrost_ptr bifrost_descs;
268
union {
269
struct {
270
struct mali_bifrost_tiler_heap_packed heap;
271
struct mali_bifrost_tiler_packed tiler;
272
} bifrost;
273
struct mali_midgard_tiler_packed midgard;
274
} templ;
275
} tiler;
276
bool issued;
277
};
278
279
struct panvk_syncobj {
280
uint32_t permanent, temporary;
281
};
282
283
enum panvk_event_op_type {
284
PANVK_EVENT_OP_SET,
285
PANVK_EVENT_OP_RESET,
286
PANVK_EVENT_OP_WAIT,
287
};
288
289
struct panvk_event_op {
290
enum panvk_event_op_type type;
291
struct panvk_event *event;
292
};
293
294
struct panvk_fence {
295
struct vk_object_base base;
296
struct panvk_syncobj syncobj;
297
};
298
299
struct panvk_semaphore {
300
struct vk_object_base base;
301
struct panvk_syncobj syncobj;
302
};
303
304
int
305
panvk_signal_syncobjs(struct panvk_device *device,
306
struct panvk_syncobj *syncobj1,
307
struct panvk_syncobj *syncobj2);
308
309
int
310
panvk_syncobj_to_fd(struct panvk_device *device,
311
struct panvk_syncobj *sync);
312
313
struct panvk_device_memory {
314
struct vk_object_base base;
315
struct panfrost_bo *bo;
316
};
317
318
struct panvk_descriptor {
319
union {
320
struct {
321
VkImageLayout layout;
322
struct panvk_image_view *view;
323
struct panvk_sampler *sampler;
324
} image;
325
326
struct {
327
struct panvk_buffer *buffer;
328
uint64_t offset;
329
uint64_t range;
330
} buffer_info;
331
332
struct panvk_buffer_view *buffer_view;
333
};
334
};
335
336
struct panvk_descriptor_set {
337
struct vk_object_base base;
338
struct panvk_descriptor_pool *pool;
339
const struct panvk_descriptor_set_layout *layout;
340
struct panvk_descriptor *descs;
341
struct mali_uniform_buffer_packed *ubos;
342
struct mali_midgard_sampler_packed *samplers;
343
union {
344
struct mali_bifrost_texture_packed *bifrost;
345
mali_ptr *midgard;
346
} textures;
347
};
348
349
#define MAX_SETS 4
350
351
struct panvk_descriptor_set_binding_layout {
352
VkDescriptorType type;
353
354
/* Number of array elements in this binding */
355
unsigned array_size;
356
357
/* Indices in the desc arrays */
358
unsigned desc_idx;
359
union {
360
struct {
361
unsigned sampler_idx;
362
unsigned tex_idx;
363
};
364
struct {
365
union {
366
unsigned ssbo_idx;
367
unsigned ubo_idx;
368
};
369
unsigned dynoffset_idx;
370
};
371
};
372
373
/* Shader stages affected by this set+binding */
374
uint16_t shader_stages;
375
376
struct panvk_sampler **immutable_samplers;
377
};
378
379
struct panvk_descriptor_set_layout {
380
struct vk_object_base base;
381
382
/* The create flags for this descriptor set layout */
383
VkDescriptorSetLayoutCreateFlags flags;
384
385
/* Shader stages affected by this descriptor set */
386
uint16_t shader_stages;
387
388
unsigned num_descs;
389
unsigned num_samplers;
390
unsigned num_textures;
391
unsigned num_ubos;
392
unsigned num_ssbos;
393
unsigned num_dynoffsets;
394
395
/* Number of bindings in this descriptor set */
396
uint32_t binding_count;
397
398
/* Bindings in this descriptor set */
399
struct panvk_descriptor_set_binding_layout bindings[0];
400
};
401
402
struct panvk_pipeline_layout {
403
struct vk_object_base base;
404
unsigned char sha1[20];
405
406
unsigned num_samplers;
407
unsigned num_textures;
408
unsigned num_ubos;
409
unsigned num_ssbos;
410
unsigned num_dynoffsets;
411
uint32_t num_sets;
412
413
struct {
414
struct panvk_descriptor_set_layout *layout;
415
unsigned sampler_offset;
416
unsigned tex_offset;
417
unsigned ubo_offset;
418
unsigned ssbo_offset;
419
unsigned dynoffset_offset;
420
} sets[MAX_SETS];
421
};
422
423
struct panvk_desc_pool_counters {
424
unsigned samplers;
425
unsigned combined_image_samplers;
426
unsigned sampled_images;
427
unsigned storage_images;
428
unsigned uniform_texel_bufs;
429
unsigned storage_texel_bufs;
430
unsigned input_attachments;
431
unsigned uniform_bufs;
432
unsigned storage_bufs;
433
unsigned uniform_dyn_bufs;
434
unsigned storage_dyn_bufs;
435
unsigned sets;
436
};
437
438
struct panvk_descriptor_pool {
439
struct vk_object_base base;
440
struct panvk_desc_pool_counters max;
441
struct panvk_desc_pool_counters cur;
442
struct panvk_descriptor_set *sets;
443
};
444
445
struct panvk_buffer {
446
struct vk_object_base base;
447
VkDeviceSize size;
448
449
VkBufferUsageFlags usage;
450
VkBufferCreateFlags flags;
451
452
struct panfrost_bo *bo;
453
VkDeviceSize bo_offset;
454
};
455
456
enum panvk_dynamic_state_bits {
457
PANVK_DYNAMIC_VIEWPORT = 1 << 0,
458
PANVK_DYNAMIC_SCISSOR = 1 << 1,
459
PANVK_DYNAMIC_LINE_WIDTH = 1 << 2,
460
PANVK_DYNAMIC_DEPTH_BIAS = 1 << 3,
461
PANVK_DYNAMIC_BLEND_CONSTANTS = 1 << 4,
462
PANVK_DYNAMIC_DEPTH_BOUNDS = 1 << 5,
463
PANVK_DYNAMIC_STENCIL_COMPARE_MASK = 1 << 6,
464
PANVK_DYNAMIC_STENCIL_WRITE_MASK = 1 << 7,
465
PANVK_DYNAMIC_STENCIL_REFERENCE = 1 << 8,
466
PANVK_DYNAMIC_DISCARD_RECTANGLE = 1 << 9,
467
PANVK_DYNAMIC_ALL = (1 << 10) - 1,
468
};
469
470
struct panvk_descriptor_state {
471
struct {
472
const struct panvk_descriptor_set *set;
473
struct panfrost_ptr dynoffsets;
474
} sets[MAX_SETS];
475
mali_ptr sysvals[MESA_SHADER_STAGES];
476
mali_ptr ubos;
477
mali_ptr textures;
478
mali_ptr samplers;
479
};
480
481
struct panvk_draw_info {
482
unsigned first_index;
483
unsigned index_count;
484
unsigned first_vertex;
485
unsigned vertex_count;
486
unsigned padded_vertex_count;
487
unsigned first_instance;
488
unsigned instance_count;
489
int vertex_offset;
490
unsigned offset_start;
491
struct mali_invocation_packed invocation;
492
struct {
493
mali_ptr varyings;
494
mali_ptr attributes;
495
mali_ptr push_constants;
496
} stages[MESA_SHADER_STAGES];
497
mali_ptr varying_bufs;
498
mali_ptr attribute_bufs;
499
mali_ptr textures;
500
mali_ptr samplers;
501
mali_ptr ubos;
502
mali_ptr position;
503
union {
504
mali_ptr psiz;
505
float line_width;
506
};
507
mali_ptr tls;
508
mali_ptr fb;
509
const struct pan_tiler_context *tiler_ctx;
510
mali_ptr fs_rsd;
511
mali_ptr viewport;
512
struct {
513
struct panfrost_ptr vertex;
514
struct panfrost_ptr tiler;
515
} jobs;
516
};
517
518
struct panvk_attrib_info {
519
unsigned buf;
520
unsigned offset;
521
enum pipe_format format;
522
};
523
524
struct panvk_attrib_buf_info {
525
bool special;
526
union {
527
struct {
528
unsigned stride;
529
bool per_instance;
530
};
531
unsigned special_id;
532
};
533
};
534
535
struct panvk_attribs_info {
536
struct panvk_attrib_info attrib[PAN_MAX_ATTRIBUTE];
537
unsigned attrib_count;
538
struct panvk_attrib_buf_info buf[PAN_MAX_ATTRIBUTE];
539
unsigned buf_count;
540
};
541
542
struct panvk_attrib_buf {
543
mali_ptr address;
544
unsigned size;
545
};
546
547
struct panvk_cmd_state {
548
VkPipelineBindPoint bind_point;
549
550
struct panvk_pipeline *pipeline;
551
552
uint32_t dirty;
553
554
struct panvk_varyings_info varyings;
555
mali_ptr fs_rsd;
556
557
struct {
558
float constants[8][4];
559
} blend;
560
561
struct {
562
struct pan_compute_dim wg_count;
563
} compute;
564
565
struct {
566
struct {
567
float constant_factor;
568
float clamp;
569
float slope_factor;
570
} depth_bias;
571
float line_width;
572
} rast;
573
574
struct {
575
struct panvk_attrib_buf bufs[MAX_VBS];
576
unsigned count;
577
mali_ptr attribs;
578
mali_ptr attrib_bufs;
579
} vb;
580
581
/* Index buffer */
582
struct {
583
struct panvk_buffer *buffer;
584
uint64_t offset;
585
uint32_t type;
586
uint32_t max_index_count;
587
uint8_t index_size;
588
uint64_t index_va;
589
} ib;
590
591
struct {
592
struct {
593
uint8_t compare_mask;
594
uint8_t write_mask;
595
uint8_t ref;
596
} s_front, s_back;
597
} zs;
598
599
const struct panvk_render_pass *pass;
600
const struct panvk_subpass *subpass;
601
const struct panvk_framebuffer *framebuffer;
602
VkRect2D render_area;
603
604
struct panvk_clear_value *clear;
605
606
mali_ptr vpd;
607
VkViewport viewport;
608
VkRect2D scissor;
609
610
struct panvk_batch *batch;
611
};
612
613
struct panvk_cmd_pool {
614
struct vk_object_base base;
615
VkAllocationCallbacks alloc;
616
struct list_head active_cmd_buffers;
617
struct list_head free_cmd_buffers;
618
uint32_t queue_family_index;
619
struct panvk_bo_pool desc_bo_pool;
620
struct panvk_bo_pool varying_bo_pool;
621
struct panvk_bo_pool tls_bo_pool;
622
};
623
624
enum panvk_cmd_buffer_status {
625
PANVK_CMD_BUFFER_STATUS_INVALID,
626
PANVK_CMD_BUFFER_STATUS_INITIAL,
627
PANVK_CMD_BUFFER_STATUS_RECORDING,
628
PANVK_CMD_BUFFER_STATUS_EXECUTABLE,
629
PANVK_CMD_BUFFER_STATUS_PENDING,
630
};
631
632
struct panvk_cmd_buffer {
633
struct vk_object_base base;
634
635
struct panvk_device *device;
636
637
struct panvk_cmd_pool *pool;
638
struct list_head pool_link;
639
struct panvk_pool desc_pool;
640
struct panvk_pool varying_pool;
641
struct panvk_pool tls_pool;
642
struct list_head batches;
643
644
VkCommandBufferUsageFlags usage_flags;
645
VkCommandBufferLevel level;
646
enum panvk_cmd_buffer_status status;
647
648
struct panvk_cmd_state state;
649
uint32_t queue_family_index;
650
651
uint8_t push_constants[MAX_PUSH_CONSTANTS_SIZE];
652
VkShaderStageFlags push_constant_stages;
653
struct panvk_descriptor_set meta_push_descriptors;
654
655
struct panvk_descriptor_state descriptors[MAX_BIND_POINTS];
656
657
VkResult record_result;
658
};
659
660
void
661
panvk_cmd_open_batch(struct panvk_cmd_buffer *cmdbuf);
662
663
void
664
panvk_cmd_close_batch(struct panvk_cmd_buffer *cmdbuf);
665
666
void
667
panvk_cmd_get_midgard_polygon_list(struct panvk_cmd_buffer *cmdbuf,
668
unsigned width, unsigned height,
669
bool has_draws);
670
671
void
672
panvk_cmd_get_bifrost_tiler_context(struct panvk_cmd_buffer *cmdbuf,
673
unsigned width, unsigned height);
674
675
void
676
panvk_pack_color(struct panvk_clear_value *out,
677
const VkClearColorValue *in,
678
enum pipe_format format);
679
680
struct panvk_event {
681
struct vk_object_base base;
682
uint32_t syncobj;
683
};
684
685
struct panvk_shader_module {
686
struct vk_object_base base;
687
unsigned char sha1[20];
688
689
uint32_t code_size;
690
const uint32_t *code[0];
691
};
692
693
struct panvk_shader {
694
struct pan_shader_info info;
695
struct util_dynarray binary;
696
unsigned sysval_ubo;
697
};
698
699
struct panvk_shader *
700
panvk_shader_create(struct panvk_device *dev,
701
gl_shader_stage stage,
702
const VkPipelineShaderStageCreateInfo *stage_info,
703
const struct panvk_pipeline_layout *layout,
704
unsigned sysval_ubo,
705
struct pan_blend_state *blend_state,
706
bool static_blend_constants,
707
const VkAllocationCallbacks *alloc);
708
709
void
710
panvk_shader_destroy(struct panvk_device *dev,
711
struct panvk_shader *shader,
712
const VkAllocationCallbacks *alloc);
713
714
union panvk_sysval_data {
715
float f32[4];
716
double f64[2];
717
uint32_t u32[4];
718
uint64_t u64[2];
719
};
720
721
struct panvk_pipeline {
722
struct vk_object_base base;
723
724
struct panvk_varyings_info varyings;
725
struct panvk_attribs_info attribs;
726
727
const struct panvk_pipeline_layout *layout;
728
729
unsigned active_stages;
730
731
uint32_t dynamic_state_mask;
732
733
struct panfrost_bo *binary_bo;
734
struct panfrost_bo *state_bo;
735
736
mali_ptr vpd;
737
mali_ptr rsds[MESA_SHADER_STAGES];
738
739
unsigned num_ubos;
740
unsigned num_sysvals;
741
742
struct {
743
unsigned ubo_idx;
744
mali_ptr ubo;
745
struct panfrost_sysvals ids;
746
uint32_t dirty_mask;
747
} sysvals[MESA_SHADER_STAGES];
748
749
unsigned tls_size;
750
unsigned wls_size;
751
752
struct {
753
mali_ptr address;
754
struct pan_shader_info info;
755
struct mali_renderer_state_packed rsd_template;
756
bool required;
757
bool dynamic_rsd;
758
} fs;
759
760
struct {
761
enum mali_draw_mode topology;
762
bool writes_point_size;
763
bool primitive_restart;
764
} ia;
765
766
struct {
767
bool clamp_depth;
768
float line_width;
769
struct {
770
bool enable;
771
float constant_factor;
772
float clamp;
773
float slope_factor;
774
} depth_bias;
775
bool front_ccw;
776
bool cull_front_face;
777
bool cull_back_face;
778
} rast;
779
780
struct {
781
bool z_test;
782
bool z_write;
783
enum mali_func z_compare_func;
784
bool s_test;
785
struct {
786
enum mali_stencil_op fail_op;
787
enum mali_stencil_op pass_op;
788
enum mali_stencil_op z_fail_op;
789
enum mali_func compare_func;
790
uint8_t compare_mask;
791
uint8_t write_mask;
792
uint8_t ref;
793
} s_front, s_back;
794
} zs;
795
796
struct {
797
uint8_t rast_samples;
798
uint8_t min_samples;
799
uint16_t sample_mask;
800
bool alpha_to_coverage;
801
bool alpha_to_one;
802
} ms;
803
804
struct {
805
struct pan_blend_state state;
806
struct mali_blend_packed bd_template[8];
807
struct {
808
uint8_t index;
809
uint16_t bifrost_factor;
810
} constant[8];
811
} blend;
812
813
VkViewport viewport;
814
VkRect2D scissor;
815
};
816
817
bool
818
panvk_blend_needs_lowering(const struct panfrost_device *dev,
819
const struct pan_blend_state *state,
820
unsigned rt);
821
822
struct panvk_image_level {
823
VkDeviceSize offset;
824
VkDeviceSize size;
825
uint32_t pitch;
826
};
827
828
struct panvk_slice_layout {
829
unsigned width;
830
unsigned height;
831
unsigned depth;
832
unsigned offset;
833
unsigned line_stride;
834
unsigned size;
835
836
/* If there is a header preceding each slice, how big is
837
* that header? Used for AFBC.
838
*/
839
unsigned afbc_header_size;
840
841
/* If checksumming is enabled following the slice, what
842
* is its offset/stride?
843
*/
844
struct {
845
unsigned offset;
846
unsigned stride;
847
unsigned size;
848
} checksum;
849
};
850
851
#define PANVK_MAX_MIP_LEVELS 13
852
853
struct panvk_plane_layout {
854
struct panvk_slice_layout slices[PANVK_MAX_MIP_LEVELS];
855
unsigned offset;
856
unsigned array_stride;
857
unsigned size;
858
};
859
860
struct panvk_plane_memory {
861
const struct panfrost_bo *bo;
862
unsigned offset;
863
};
864
865
#define PANVK_MAX_PLANES 1
866
867
struct panvk_image {
868
struct vk_object_base base;
869
struct pan_image pimage;
870
VkImageType type;
871
872
/* The original VkFormat provided by the client. This may not match any
873
* of the actual surface formats.
874
*/
875
VkFormat vk_format;
876
VkImageAspectFlags aspects;
877
VkImageUsageFlags usage; /**< Superset of VkImageCreateInfo::usage. */
878
VkImageTiling tiling; /** VkImageCreateInfo::tiling */
879
VkImageCreateFlags flags; /** VkImageCreateInfo::flags */
880
VkExtent3D extent;
881
882
unsigned queue_family_mask;
883
bool exclusive;
884
bool shareable;
885
};
886
887
unsigned
888
panvk_image_get_plane_size(const struct panvk_image *image, unsigned plane);
889
890
unsigned
891
panvk_image_get_total_size(const struct panvk_image *image);
892
893
struct panvk_image_view {
894
struct vk_object_base base;
895
struct pan_image_view pview;
896
897
VkFormat vk_format;
898
struct panfrost_bo *bo;
899
struct {
900
struct mali_bifrost_texture_packed tex_desc;
901
} bifrost;
902
};
903
904
struct panvk_sampler {
905
struct vk_object_base base;
906
struct mali_midgard_sampler_packed desc;
907
};
908
909
struct panvk_buffer_view {
910
struct vk_object_base base;
911
};
912
913
struct panvk_attachment_info {
914
struct panvk_image_view *iview;
915
};
916
917
struct panvk_framebuffer {
918
struct vk_object_base base;
919
920
uint32_t width;
921
uint32_t height;
922
uint32_t layers;
923
924
uint32_t attachment_count;
925
struct panvk_attachment_info attachments[0];
926
};
927
928
struct panvk_clear_value {
929
union {
930
uint32_t color[4];
931
struct {
932
float depth;
933
uint8_t stencil;
934
};
935
};
936
};
937
938
struct panvk_subpass_attachment {
939
uint32_t idx;
940
VkImageLayout layout;
941
bool clear;
942
};
943
944
struct panvk_subpass {
945
uint32_t input_count;
946
uint32_t color_count;
947
struct panvk_subpass_attachment *input_attachments;
948
uint8_t active_color_attachments;
949
struct panvk_subpass_attachment *color_attachments;
950
struct panvk_subpass_attachment *resolve_attachments;
951
struct panvk_subpass_attachment zs_attachment;
952
953
uint32_t view_mask;
954
};
955
956
struct panvk_render_pass_attachment {
957
VkAttachmentDescriptionFlags flags;
958
enum pipe_format format;
959
unsigned samples;
960
VkAttachmentLoadOp load_op;
961
VkAttachmentStoreOp store_op;
962
VkAttachmentLoadOp stencil_load_op;
963
VkAttachmentStoreOp stencil_store_op;
964
VkImageLayout initial_layout;
965
VkImageLayout final_layout;
966
unsigned view_mask;
967
unsigned clear_subpass;
968
};
969
970
struct panvk_render_pass {
971
struct vk_object_base base;
972
973
uint32_t attachment_count;
974
uint32_t subpass_count;
975
struct panvk_subpass_attachment *subpass_attachments;
976
struct panvk_render_pass_attachment *attachments;
977
struct panvk_subpass subpasses[0];
978
};
979
980
static inline enum mali_func
981
panvk_translate_compare_func(VkCompareOp comp)
982
{
983
STATIC_ASSERT(VK_COMPARE_OP_NEVER == (VkCompareOp)MALI_FUNC_NEVER);
984
STATIC_ASSERT(VK_COMPARE_OP_LESS == (VkCompareOp)MALI_FUNC_LESS);
985
STATIC_ASSERT(VK_COMPARE_OP_EQUAL == (VkCompareOp)MALI_FUNC_EQUAL);
986
STATIC_ASSERT(VK_COMPARE_OP_LESS_OR_EQUAL == (VkCompareOp)MALI_FUNC_LEQUAL);
987
STATIC_ASSERT(VK_COMPARE_OP_GREATER == (VkCompareOp)MALI_FUNC_GREATER);
988
STATIC_ASSERT(VK_COMPARE_OP_NOT_EQUAL == (VkCompareOp)MALI_FUNC_NOT_EQUAL);
989
STATIC_ASSERT(VK_COMPARE_OP_GREATER_OR_EQUAL == (VkCompareOp)MALI_FUNC_GEQUAL);
990
STATIC_ASSERT(VK_COMPARE_OP_ALWAYS == (VkCompareOp)MALI_FUNC_ALWAYS);
991
992
return (enum mali_func)comp;
993
}
994
995
VK_DEFINE_HANDLE_CASTS(panvk_cmd_buffer, base, VkCommandBuffer, VK_OBJECT_TYPE_COMMAND_BUFFER)
996
VK_DEFINE_HANDLE_CASTS(panvk_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE)
997
VK_DEFINE_HANDLE_CASTS(panvk_instance, vk.base, VkInstance, VK_OBJECT_TYPE_INSTANCE)
998
VK_DEFINE_HANDLE_CASTS(panvk_physical_device, vk.base, VkPhysicalDevice, VK_OBJECT_TYPE_PHYSICAL_DEVICE)
999
VK_DEFINE_HANDLE_CASTS(panvk_queue, base, VkQueue, VK_OBJECT_TYPE_QUEUE)
1000
1001
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_cmd_pool, base, VkCommandPool, VK_OBJECT_TYPE_COMMAND_POOL)
1002
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_buffer, base, VkBuffer, VK_OBJECT_TYPE_BUFFER)
1003
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_buffer_view, base, VkBufferView, VK_OBJECT_TYPE_BUFFER_VIEW)
1004
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_pool, base, VkDescriptorPool, VK_OBJECT_TYPE_DESCRIPTOR_POOL)
1005
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_set, base, VkDescriptorSet, VK_OBJECT_TYPE_DESCRIPTOR_SET)
1006
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_descriptor_set_layout, base,
1007
VkDescriptorSetLayout, VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT)
1008
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_device_memory, base, VkDeviceMemory, VK_OBJECT_TYPE_DEVICE_MEMORY)
1009
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_fence, base, VkFence, VK_OBJECT_TYPE_FENCE)
1010
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_event, base, VkEvent, VK_OBJECT_TYPE_EVENT)
1011
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_framebuffer, base, VkFramebuffer, VK_OBJECT_TYPE_FRAMEBUFFER)
1012
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image, base, VkImage, VK_OBJECT_TYPE_IMAGE)
1013
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_image_view, base, VkImageView, VK_OBJECT_TYPE_IMAGE_VIEW);
1014
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_cache, base, VkPipelineCache, VK_OBJECT_TYPE_PIPELINE_CACHE)
1015
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline, base, VkPipeline, VK_OBJECT_TYPE_PIPELINE)
1016
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_pipeline_layout, base, VkPipelineLayout, VK_OBJECT_TYPE_PIPELINE_LAYOUT)
1017
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_render_pass, base, VkRenderPass, VK_OBJECT_TYPE_RENDER_PASS)
1018
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_sampler, base, VkSampler, VK_OBJECT_TYPE_SAMPLER)
1019
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_shader_module, base, VkShaderModule, VK_OBJECT_TYPE_SHADER_MODULE)
1020
VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_semaphore, base, VkSemaphore, VK_OBJECT_TYPE_SEMAPHORE)
1021
1022
#endif /* PANVK_PRIVATE_H */
1023
1024