xref: /aosp_15_r20/external/mesa3d/src/intel/shaders/libintel_shaders.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /* Copyright © 2023 Intel Corporation
2  * SPDX-License-Identifier: MIT
3  */
4 
5 #ifndef _LIBANV_SHADERS_H_
6 #define _LIBANV_SHADERS_H_
7 
8 /* Define stdint types compatible between the CPU and GPU for shared headers */
9 #ifndef __OPENCL_VERSION__
10 #include <stdint.h>
11 
12 #include "util/macros.h"
13 
14 #else
15 #define BITFIELD_BIT(i) (1u << i)
16 
17 typedef ulong uint64_t;
18 typedef uint uint32_t;
19 typedef ushort uint16_t;
20 typedef uchar uint8_t;
21 
22 typedef long int64_t;
23 typedef int int32_t;
24 typedef short int16_t;
25 typedef char int8_t;
26 
27 typedef struct VkDrawIndexedIndirectCommand {
28     uint32_t    indexCount;
29     uint32_t    instanceCount;
30     uint32_t    firstIndex;
31     int32_t     vertexOffset;
32     uint32_t    firstInstance;
33 } VkDrawIndexedIndirectCommand __attribute__((aligned(4)));
34 
35 typedef struct VkDrawIndirectCommand {
36     uint32_t    vertexCount;
37     uint32_t    instanceCount;
38     uint32_t    firstVertex;
39     uint32_t    firstInstance;
40 } VkDrawIndirectCommand __attribute__((aligned(4)));
41 
42 #include "genxml/gen_macros.h"
43 #include "genxml/genX_cl_pack.h"
44 #endif
45 
46 /**
47  * Flags for generated_draws.cl
48  */
49 #define ANV_GENERATED_FLAG_INDEXED    BITFIELD_BIT(0)
50 #define ANV_GENERATED_FLAG_PREDICATED BITFIELD_BIT(1)
51 /* Only used on Gfx9, means the pipeline is using gl_DrawID */
52 #define ANV_GENERATED_FLAG_DRAWID     BITFIELD_BIT(2)
53 /* Only used on Gfx9, means the pipeline is using gl_BaseVertex or
54  * gl_BaseInstance
55  */
56 #define ANV_GENERATED_FLAG_BASE       BITFIELD_BIT(3)
57 /* Whether the count is indirect  */
58 #define ANV_GENERATED_FLAG_COUNT      BITFIELD_BIT(4)
59 /* Whether the generation shader writes to the ring buffer */
60 #define ANV_GENERATED_FLAG_RING_MODE  BITFIELD_BIT(5)
61 /* Whether TBIMR tile-based rendering shall be enabled. */
62 #define ANV_GENERATED_FLAG_TBIMR      BITFIELD_BIT(6)
63 
64 /**
65  * Flags for query_copy.cl
66  */
67 #define ANV_COPY_QUERY_FLAG_RESULT64  BITFIELD_BIT(0)
68 #define ANV_COPY_QUERY_FLAG_AVAILABLE BITFIELD_BIT(1)
69 #define ANV_COPY_QUERY_FLAG_DELTA     BITFIELD_BIT(2)
70 #define ANV_COPY_QUERY_FLAG_PARTIAL   BITFIELD_BIT(3)
71 
72 #ifdef __OPENCL_VERSION__
73 
74 void genX(write_3DSTATE_VERTEX_BUFFERS)(global void *dst_ptr,
75                                         uint32_t buffer_count);
76 
77 void genX(write_VERTEX_BUFFER_STATE)(global void *dst_ptr,
78                                      uint32_t mocs,
79                                      uint32_t buffer_idx,
80                                      uint64_t address,
81                                      uint32_t size,
82                                      uint32_t stride);
83 
84 void genX(write_3DPRIMITIVE)(global void *dst_ptr,
85                              bool is_predicated,
86                              bool is_indexed,
87                              bool use_tbimr,
88                              uint32_t vertex_count_per_instance,
89                              uint32_t start_vertex_location,
90                              uint32_t instance_count,
91                              uint32_t start_instance_location,
92                              uint32_t base_vertex_location);
93 
94 #if GFX_VER >= 11
95 void genX(write_3DPRIMITIVE_EXTENDED)(global void *dst_ptr,
96                                       bool is_predicated,
97                                       bool is_indexed,
98                                       bool use_tbimr,
99                                       uint32_t vertex_count_per_instance,
100                                       uint32_t start_vertex_location,
101                                       uint32_t instance_count,
102                                       uint32_t start_instance_location,
103                                       uint32_t base_vertex_location,
104                                       uint32_t param_base_vertex,
105                                       uint32_t param_base_instance,
106                                       uint32_t param_draw_id);
107 #endif
108 
109 void genX(write_MI_BATCH_BUFFER_START)(global void *dst_ptr, uint64_t addr);
110 
111 void genX(write_draw)(global uint32_t *dst_ptr,
112                       global void *indirect_ptr,
113                       global uint32_t *draw_id_ptr,
114                       uint32_t draw_id,
115                       uint32_t instance_multiplier,
116                       bool is_indexed,
117                       bool is_predicated,
118                       bool uses_tbimr,
119                       bool uses_base,
120                       bool uses_draw_id,
121                       uint32_t mocs);
122 
123 #endif /* __OPENCL_VERSION__ */
124 
125 #endif /* _LIBANV_SHADERS_H_ */
126