Skip to content

Commit b3ed5e5

Browse files
lwesiersZuul
authored and
Zuul
committed
Sync change.
Change-Id: I968f7527a9b3dd0806312c4250c8ec0004f29a3c
1 parent df2bee7 commit b3ed5e5

File tree

4 files changed

+192
-281
lines changed

4 files changed

+192
-281
lines changed

IGC/AdaptorOCL/ocl_igc_shared/gtpin/gtpin_driver_common.h

+154-65
Original file line numberDiff line numberDiff line change
@@ -24,99 +24,80 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2424
2525
======================= end_copyright_notice ==================================*/
2626

27-
#ifndef GPTIN_DRIVER_COMMON_H
28-
#define GPTIN_DRIVER_COMMON_H
27+
#ifndef _GPTIN_DRIVER_COMMON_
28+
#define _GPTIN_DRIVER_COMMON_
2929

3030
#include <stdint.h>
3131

3232
#ifdef _WIN32
33-
#define GTPIN_DRIVER_CALLCONV __fastcall
33+
#define GTPIN_DRIVER_CALLCONV __fastcall
3434
#else
35-
#define GTPIN_DRIVER_CALLCONV
35+
#define GTPIN_DRIVER_CALLCONV
3636
#endif
3737

3838
/************************************************************************/
3939
/* Data Types */
4040
/************************************************************************/
4141
namespace gtpin
4242
{
43-
/// GTPin <-> Driver interface version
4443

45-
static const uint16_t GTPIN_COMMON_INTERFACE_VERSION = 6;
44+
// GTPin <-> Driver interface version
4645

46+
static const uint16_t GTPIN_COMMON_INTERFACE_VERSION = 3;
4747

48-
/*!
48+
/*
4949
* Common Interface Changelog:
50-
* 6. Added back context_handle_t for backward compatibility
51-
* 5. Added driver interface
52-
* 4. Removed GenerateDriverInterfaceVersion function
5350
* 3. Added command_buffer_handle_s for OpenCL support
5451
* 2. Added GTPIN_DRIVER_CALLCONV
5552
* 1. First introduction of GTPIN_COMMON_INTERFACE_VERSION, addition of debug_data,
5653
* 0. Not supported
5754
*/
5855

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
6661

6762
typedef struct interface_version_s
6863
{
6964
uint16_t specific;
7065
uint16_t common;
7166
} interface_version_t;
7267

73-
7468
/**
75-
* Gen Version
76-
*/
69+
Gen Version
70+
*/
7771
typedef enum
7872
{
7973
GTPIN_GEN_INVALID,
8074
GTPIN_GEN_8,
8175
GTPIN_GEN_9,
8276
GTPIN_GEN_10,
83-
GTPIN_GEN_11,
77+
GTPIN_GEN_11
8478
} GTPIN_GEN_VERSION;
8579

86-
87-
/*!
88-
* Possible results of GTPin driver interface functions
89-
*/
9080
typedef enum
9181
{
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
9988
} GTPIN_DI_STATUS;
10089

101-
102-
/*!
103-
* Kernel types
104-
*/
10590
typedef enum
10691
{
10792
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
11499
} GTPIN_KERNEL_TYPE;
115100

116-
117-
/*!
118-
* SIMD widths
119-
*/
120101
typedef enum
121102
{
122103
GTPIN_SIMD_INVALID,
@@ -127,35 +108,143 @@ typedef enum
127108
} GTPIN_SIMD_WIDTH;
128109

129110

130-
/*!
131-
* GPU interfaces
132-
*/
111+
/**
112+
Resource addressing mode
113+
*/
133114
typedef enum
134115
{
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;
139120

140-
/*!
141-
* Platform information
142-
*/
121+
/**
122+
Platform info structure
123+
*/
143124
typedef struct platform_info_s
144125
{
145-
GTPIN_GEN_VERSION gen_version; /// should match KMD definition
126+
GTPIN_GEN_VERSION gen_version;
146127
uint32_t device_id;
128+
147129
} platform_info_t;
148130

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;
149140

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
154236
{
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
158241

242+
} driver_services_t;
159243

244+
inline uint32_t GenerateDriverInterfaceVersion(uint16_t common_version, uint16_t specific_version)
245+
{
246+
return (common_version << 16) | specific_version;
160247
}
161-
#endif /// GPTIN_DRIVER_COMMON_H
248+
249+
}
250+
#endif

0 commit comments

Comments
 (0)