@@ -24,99 +24,80 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
24
25
25
======================= end_copyright_notice ==================================*/
26
26
27
- #ifndef GPTIN_DRIVER_COMMON_H
28
- #define GPTIN_DRIVER_COMMON_H
27
+ #ifndef _GPTIN_DRIVER_COMMON_
28
+ #define _GPTIN_DRIVER_COMMON_
29
29
30
30
#include < stdint.h>
31
31
32
32
#ifdef _WIN32
33
- #define GTPIN_DRIVER_CALLCONV __fastcall
33
+ #define GTPIN_DRIVER_CALLCONV __fastcall
34
34
#else
35
- #define GTPIN_DRIVER_CALLCONV
35
+ #define GTPIN_DRIVER_CALLCONV
36
36
#endif
37
37
38
38
/* ***********************************************************************/
39
39
/* Data Types */
40
40
/* ***********************************************************************/
41
41
namespace gtpin
42
42
{
43
- // / GTPin <-> Driver interface version
44
43
45
- static const uint16_t GTPIN_COMMON_INTERFACE_VERSION = 6 ;
44
+ // GTPin <-> Driver interface version
46
45
46
+ static const uint16_t GTPIN_COMMON_INTERFACE_VERSION = 3 ;
47
47
48
- /* !
48
+ /*
49
49
* Common Interface Changelog:
50
- * 6. Added back context_handle_t for backward compatibility
51
- * 5. Added driver interface
52
- * 4. Removed GenerateDriverInterfaceVersion function
53
50
* 3. Added command_buffer_handle_s for OpenCL support
54
51
* 2. Added GTPIN_DRIVER_CALLCONV
55
52
* 1. First introduction of GTPIN_COMMON_INTERFACE_VERSION, addition of debug_data,
56
53
* 0. Not supported
57
54
*/
58
55
59
-
60
- typedef struct resource_handle_s * resource_handle_t ; // / driver's handle to the resource
61
- typedef struct device_handle_s * device_handle_t ; // / driver's handle to the device
62
- typedef device_handle_t context_handle_t ; // / for backward compatibility
63
- typedef struct igc_init_s igc_init_t ; // / info passed by IGC
64
- typedef struct igc_info_s igc_info_t ; // / info passed by IGC
65
-
56
+ typedef struct resource_handle_s * resource_handle_t ; // driver's handle to the resource
57
+ typedef struct context_handle_s * context_handle_t ; // driver's handle to the context/device
58
+ typedef struct command_buffer_handle_s * command_buffer_handle_t ; // driver's handle to the command buffer
59
+ typedef struct igc_init_s igc_init_t ; // info passed by IGC
60
+ typedef struct igc_info_s igc_info_t ; // info passed by IGC
66
61
67
62
typedef struct interface_version_s
68
63
{
69
64
uint16_t specific;
70
65
uint16_t common;
71
66
} interface_version_t ;
72
67
73
-
74
68
/* *
75
- * Gen Version
76
- */
69
+ Gen Version
70
+ */
77
71
typedef enum
78
72
{
79
73
GTPIN_GEN_INVALID,
80
74
GTPIN_GEN_8,
81
75
GTPIN_GEN_9,
82
76
GTPIN_GEN_10,
83
- GTPIN_GEN_11,
77
+ GTPIN_GEN_11
84
78
} GTPIN_GEN_VERSION;
85
79
86
-
87
- /* !
88
- * Possible results of GTPin driver interface functions
89
- */
90
80
typedef enum
91
81
{
92
- GTPIN_DI_SUCCESS = 0 , // / operation is successful
93
- GTPIN_DI_ERROR_INVALID_ARGUMENT, // / one of the arguments is invalid (null)
94
- GTPIN_DI_ERROR_NO_INSTANCE, // / no instance of GTPin inside the driver
95
- GTPIN_DI_ERROR_INSTANCE_ALREADY_CREATED, // / GTPin was already initialized in the driver
96
- GTPIN_DI_ERROR_ALLOCATION_FAILED, // / failed to allocate a buffer
97
- GTPIN_DI_ERROR_NO_VIRTUAL_ADDRESS_TO_BUFFER, // / failed to obtain virtual address to the buffer
98
- GTPIN_DI_FAIL, // / general failure
82
+ GTPIN_DI_SUCCESS = 0 ,
83
+ GTPIN_DI_ERROR_INVALID_ARGUMENT,
84
+ GTPIN_DI_ERROR_NO_INSTANCE, // no instance of GTPin inside the driver
85
+ GTPIN_DI_ERROR_INSTANCE_ALREADY_CREATED, // GTPin was already initialized in the driver
86
+ GTPIN_DI_ERROR_ALLOCATION_FAILED, // failed to allocate a buffer
87
+ GTPIN_DI_ERROR_NO_VIRTUAL_ADDRESS_TO_BUFFER, // failed to obtain virtual address to the buffer
99
88
} GTPIN_DI_STATUS;
100
89
101
-
102
- /* !
103
- * Kernel types
104
- */
105
90
typedef enum
106
91
{
107
92
GTPIN_KERNEL_TYPE_INVALID,
108
- GTPIN_KERNEL_TYPE_HS, / / / Hull Shader
109
- GTPIN_KERNEL_TYPE_DS, / / / Domain Shader
110
- GTPIN_KERNEL_TYPE_VS, / / / Vertex Shader
111
- GTPIN_KERNEL_TYPE_PS, / / / Pixel Shader
112
- GTPIN_KERNEL_TYPE_CS, / / / Compute Shader (GPGPU)
113
- GTPIN_KERNEL_TYPE_GS / / / Geometry Shader
93
+ GTPIN_KERNEL_TYPE_HS, // Hull Shader
94
+ GTPIN_KERNEL_TYPE_DS, // Domain Shader
95
+ GTPIN_KERNEL_TYPE_VS, // Vertex Shader
96
+ GTPIN_KERNEL_TYPE_PS, // Pixel Shader
97
+ GTPIN_KERNEL_TYPE_CS, // Compute Shader (GPGPU)
98
+ GTPIN_KERNEL_TYPE_GS // Geometry Shader
114
99
} GTPIN_KERNEL_TYPE;
115
100
116
-
117
- /* !
118
- * SIMD widths
119
- */
120
101
typedef enum
121
102
{
122
103
GTPIN_SIMD_INVALID,
@@ -127,35 +108,143 @@ typedef enum
127
108
} GTPIN_SIMD_WIDTH;
128
109
129
110
130
- /* !
131
- * GPU interfaces
132
- */
111
+ /* *
112
+ Resource addressing mode
113
+ */
133
114
typedef enum
134
115
{
135
- GFX_OPENCL,
136
- GFX_CM,
137
- } GFX_TARGET;
138
-
116
+ GTPIN_BUFFER_BINDFULL, // using binding table index
117
+ GTPIN_BUFFER_BINDLESS, // using an offset to the surface table in a register
118
+ GTPIN_BUFFER_STATELESS, // using an address to the resource in a register
119
+ } GTPIN_BUFFER_TYPE;
139
120
140
- /* !
141
- * Platform information
142
- */
121
+ /* *
122
+ Platform info structure
123
+ */
143
124
typedef struct platform_info_s
144
125
{
145
- GTPIN_GEN_VERSION gen_version; // / should match KMD definition
126
+ GTPIN_GEN_VERSION gen_version;
146
127
uint32_t device_id;
128
+
147
129
} platform_info_t ;
148
130
131
+ /* *
132
+ The offest of the register in the GRF.
133
+ e.g. r2.5(dw) will be represented as 2*256 + 5*4
134
+ */
135
+ typedef struct reg_desc_s
136
+ {
137
+ uint32_t reg_offset; // the location of the register in the GRF (in bytes)
138
+ uint32_t size; // size of the register in bytes
139
+ } reg_desc_t ;
149
140
150
- /* !
151
- * Driver information
152
- */
153
- typedef struct driver_info_s
141
+ /* *
142
+ Buffer's descriptor - could be:
143
+ 1. BTI - binding table index (in bindfull buffer addressing)
144
+ 2. register (in bindless / stateless buffer addressing)
145
+ */
146
+ typedef union buffer_desc_s
147
+ {
148
+ uint32_t BTI;
149
+ reg_desc_t reg_desc;
150
+ } buffer_desc_t ;
151
+
152
+
153
+ /* *
154
+ kernel instrumentation parameters structure:
155
+ */
156
+ typedef struct instrument_params_s
157
+ {
158
+ GTPIN_KERNEL_TYPE kernel_type;
159
+ GTPIN_SIMD_WIDTH simd;
160
+ const uint8_t * orig_kernel_binary; // the original kernel binary
161
+ uint32_t orig_kernel_size; // size of the kernel binary in bytes
162
+
163
+ GTPIN_BUFFER_TYPE buffer_type;
164
+ buffer_desc_t buffer_desc;
165
+ uint64_t igc_hash_id;
166
+
167
+ char * kernel_name; // the kernel name
168
+ const igc_info_t * igc_info; // information form IGC
169
+
170
+ // START Exists only from COMMON_SUPPORTED_FEATURE_SOURCELINE_MAPPING
171
+ const void * debug_data; // debug data including the elf file
172
+ uint32_t debug_data_size; // size of the elf file in bytes
173
+ // End Exists only from COMMON_SUPPORTED_FEATURE_SOURCELINE_MAPPING
174
+ } instrument_params_in_t ;
175
+
176
+
177
+ /* *
178
+ kernel instrumented data structure:
179
+ */
180
+ typedef struct instrument_params_out_s
181
+ {
182
+ uint8_t * inst_kernel_binary; // the instrumented binary
183
+ uint32_t inst_kernel_size; // size in bytes on the instrumented binary
184
+ uint64_t kernel_id; // GTPin's associated kernel id
185
+ } instrument_params_out_t ;
186
+
187
+
188
+ /* *
189
+ Allocate a buffer(resource) for GTPin
190
+
191
+ Params:
192
+ (in) context - The handle to the context
193
+ (in) size - Size of the buffer to allocate
194
+ (out) resource - The handle to the created resource
195
+ */
196
+ typedef GTPIN_DI_STATUS (GTPIN_DRIVER_CALLCONV *BufferAllocateFPTR)(context_handle_t context, uint32_t size, resource_handle_t * resource);
197
+
198
+ /* *
199
+ Deallocate GTPin's buffer
200
+
201
+ Params:
202
+ (in) context - The handle to the context
203
+ (in) resource - The handle to the resource
204
+ */
205
+ typedef GTPIN_DI_STATUS (GTPIN_DRIVER_CALLCONV *BufferDeallocateFPTR)(context_handle_t context, resource_handle_t resource);
206
+
207
+ /* *
208
+ Map GTPin's buffer to obtain the virtual address
209
+ Params:
210
+
211
+ (in) context - The handle to the context
212
+ (in) resource - The handle to the resource
213
+ (out) address - The virtual address of the resource
214
+
215
+ */
216
+ typedef GTPIN_DI_STATUS (GTPIN_DRIVER_CALLCONV *BufferMapFPTR)(context_handle_t context, resource_handle_t resource, uint8_t ** address);
217
+
218
+ /* *
219
+ UnMap GTPin's allocated buffer
220
+
221
+ Params:
222
+ (in) context - The handle to the context
223
+ (in) resource - The handle to the resource
224
+
225
+ */
226
+ typedef GTPIN_DI_STATUS (GTPIN_DRIVER_CALLCONV *BufferUnMapFPTR)(context_handle_t context, resource_handle_t resource);
227
+
228
+
229
+ /* ***********************************************************************/
230
+ /* Services (GTPin -> Driver) */
231
+ /* The following functions are implemented by the driver */
232
+ /* and called by GTPin */
233
+ /* ***********************************************************************/
234
+
235
+ typedef struct driver_services_s
154
236
{
155
- interface_version_t version; // / interface version supported by the driver
156
- GFX_TARGET gfx_target;
157
- } driver_info_t ;
237
+ BufferAllocateFPTR bufferAllocate; // request the Driver to allocate a buffer
238
+ BufferDeallocateFPTR bufferDeallocate; // request the Driver to de-allocate a buffer
239
+ BufferMapFPTR bufferMap; // request the Driver to map a buffer
240
+ BufferUnMapFPTR bufferUnMap; // request the Driver to unmap a buffer
158
241
242
+ } driver_services_t ;
159
243
244
+ inline uint32_t GenerateDriverInterfaceVersion (uint16_t common_version, uint16_t specific_version)
245
+ {
246
+ return (common_version << 16 ) | specific_version;
160
247
}
161
- #endif // / GPTIN_DRIVER_COMMON_H
248
+
249
+ }
250
+ #endif
0 commit comments