• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 PRAGMA_POISON(param)
16 #define BITFIELD_BIT(i) (1u << i)
17 
18 typedef ulong uint64_t;
19 typedef uint uint32_t;
20 typedef ushort uint16_t;
21 typedef uchar uint8_t;
22 
23 typedef long int64_t;
24 typedef int int32_t;
25 typedef short int16_t;
26 typedef char int8_t;
27 
28 typedef struct VkDrawIndexedIndirectCommand {
29     uint32_t    indexCount;
30     uint32_t    instanceCount;
31     uint32_t    firstIndex;
32     int32_t     vertexOffset;
33     uint32_t    firstInstance;
34 } VkDrawIndexedIndirectCommand __attribute__((aligned(4)));
35 
36 typedef struct VkDrawIndirectCommand {
37     uint32_t    vertexCount;
38     uint32_t    instanceCount;
39     uint32_t    firstVertex;
40     uint32_t    firstInstance;
41 } VkDrawIndirectCommand __attribute__((aligned(4)));
42 
43 #include "genxml/gen_macros.h"
44 #include "genxml/genX_cl_pack.h"
45 #endif
46 
47 /**
48  * Flags for generated_draws.cl
49  */
50 enum anv_generated_draw_flags {
51    ANV_GENERATED_FLAG_INDEXED        = BITFIELD_BIT(0),
52    ANV_GENERATED_FLAG_PREDICATED     = BITFIELD_BIT(1),
53    /* Only used on Gfx9, means the pipeline is using gl_DrawID */
54    ANV_GENERATED_FLAG_DRAWID         = BITFIELD_BIT(2),
55    /* Only used on Gfx9, means the pipeline is using gl_BaseVertex or
56     * gl_BaseInstance
57     */
58    ANV_GENERATED_FLAG_BASE           = BITFIELD_BIT(3),
59    /* Whether the count is indirect  */
60    ANV_GENERATED_FLAG_COUNT          = BITFIELD_BIT(4),
61    /* Whether the generation shader writes to the ring buffer */
62    ANV_GENERATED_FLAG_RING_MODE      = BITFIELD_BIT(5),
63    /* Whether TBIMR tile-based rendering shall be enabled. */
64    ANV_GENERATED_FLAG_TBIMR          = BITFIELD_BIT(6),
65    /* Wa_16011107343 */
66    ANV_GENERATED_FLAG_WA_16011107343 = BITFIELD_BIT(7),
67    /* Wa_22018402687 */
68    ANV_GENERATED_FLAG_WA_22018402687 = BITFIELD_BIT(8),
69 };
70 
71 /**
72  * Flags for query_copy.cl
73  */
74 #define ANV_COPY_QUERY_FLAG_RESULT64  BITFIELD_BIT(0)
75 #define ANV_COPY_QUERY_FLAG_AVAILABLE BITFIELD_BIT(1)
76 #define ANV_COPY_QUERY_FLAG_DELTA     BITFIELD_BIT(2)
77 #define ANV_COPY_QUERY_FLAG_PARTIAL   BITFIELD_BIT(3)
78 
79 #ifdef __OPENCL_VERSION__
80 
81 void genX(write_3DSTATE_VERTEX_BUFFERS)(global void *dst_ptr,
82                                         uint32_t buffer_count);
83 
84 void genX(write_VERTEX_BUFFER_STATE)(global void *dst_ptr,
85                                      uint32_t mocs,
86                                      uint32_t buffer_idx,
87                                      uint64_t address,
88                                      uint32_t size,
89                                      uint32_t stride);
90 
91 void genX(write_3DPRIMITIVE)(global void *dst_ptr,
92                              bool is_predicated,
93                              bool is_indexed,
94                              bool use_tbimr,
95                              uint32_t vertex_count_per_instance,
96                              uint32_t start_vertex_location,
97                              uint32_t instance_count,
98                              uint32_t start_instance_location,
99                              uint32_t base_vertex_location);
100 
101 #if GFX_VER >= 11
102 void genX(write_3DPRIMITIVE_EXTENDED)(global void *dst_ptr,
103                                       bool is_predicated,
104                                       bool is_indexed,
105                                       bool use_tbimr,
106                                       uint32_t vertex_count_per_instance,
107                                       uint32_t start_vertex_location,
108                                       uint32_t instance_count,
109                                       uint32_t start_instance_location,
110                                       uint32_t base_vertex_location,
111                                       uint32_t param_base_vertex,
112                                       uint32_t param_base_instance,
113                                       uint32_t param_draw_id);
114 #endif
115 
116 void genX(write_MI_BATCH_BUFFER_START)(global void *dst_ptr, uint64_t addr);
117 
118 void genX(write_draw)(global uint32_t *dst_ptr,
119                       global void *indirect_ptr,
120                       global uint32_t *draw_id_ptr,
121                       uint32_t draw_id,
122                       uint32_t instance_multiplier,
123                       bool is_indexed,
124                       bool is_predicated,
125                       bool uses_tbimr,
126                       bool uses_base,
127                       bool uses_draw_id,
128                       uint32_t mocs);
129 
130 void genX(copy_data)(global void *dst_ptr,
131                      global void *src_ptr,
132                      uint32_t size);
133 
134 #endif /* __OPENCL_VERSION__ */
135 
136 #endif /* _LIBANV_SHADERS_H_ */
137