Skip to content

Commit 30580c6

Browse files
paigealegfxbot
authored andcommitted
Adding header files with callback info for GTPin.
Change-Id: I6269d31e33245fa946ea1e2abb32242aa1e538eb
1 parent eb2d77d commit 30580c6

File tree

2 files changed

+405
-0
lines changed

2 files changed

+405
-0
lines changed
Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
/*===================== begin_copyright_notice ==================================
2+
3+
Copyright (c) 2017 Intel Corporation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a
6+
copy of this software and associated documentation files (the
7+
"Software"), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included
14+
in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
24+
25+
======================= end_copyright_notice ==================================*/
26+
27+
#ifndef _GPTIN_DRIVER_COMMON_
28+
#define _GPTIN_DRIVER_COMMON_
29+
30+
#include <stdint.h>
31+
32+
#ifdef _WIN32
33+
#define GTPIN_DRIVER_CALLCONV __fastcall
34+
#else
35+
#define GTPIN_DRIVER_CALLCONV
36+
#endif
37+
38+
/************************************************************************/
39+
/* Data Types */
40+
/************************************************************************/
41+
namespace gtpin
42+
{
43+
44+
// GTPin <-> Driver interface version
45+
46+
static const uint16_t GTPIN_COMMON_INTERFACE_VERSION = 3;
47+
48+
/*
49+
* Common Interface Changelog:
50+
* 3. Added command_buffer_handle_s for OpenCL support
51+
* 2. Added GTPIN_DRIVER_CALLCONV
52+
* 1. First introduction of GTPIN_COMMON_INTERFACE_VERSION, addition of debug_data,
53+
* 0. Not supported
54+
*/
55+
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
61+
62+
typedef struct interface_version_s
63+
{
64+
uint16_t specific;
65+
uint16_t common;
66+
} interface_version_t;
67+
68+
/**
69+
Gen Version
70+
*/
71+
typedef enum
72+
{
73+
GTPIN_GEN_INVALID,
74+
GTPIN_GEN_8,
75+
GTPIN_GEN_9,
76+
GTPIN_GEN_10,
77+
GTPIN_GEN_11
78+
} GTPIN_GEN_VERSION;
79+
80+
typedef enum
81+
{
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
88+
} GTPIN_DI_STATUS;
89+
90+
typedef enum
91+
{
92+
GTPIN_KERNEL_TYPE_INVALID,
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
99+
} GTPIN_KERNEL_TYPE;
100+
101+
typedef enum
102+
{
103+
GTPIN_SIMD_INVALID,
104+
GTPIN_SIMD_4x2 = 4,
105+
GTPIN_SIMD_8 = 8,
106+
GTPIN_SIMD_16 = 16,
107+
GTPIN_SIMD_32 = 32
108+
} GTPIN_SIMD_WIDTH;
109+
110+
111+
/**
112+
Resource addressing mode
113+
*/
114+
typedef enum
115+
{
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;
120+
121+
/**
122+
Platform info structure
123+
*/
124+
typedef struct platform_info_s
125+
{
126+
GTPIN_GEN_VERSION gen_version;
127+
uint32_t device_id;
128+
129+
} platform_info_t;
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;
140+
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
236+
{
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
241+
242+
} driver_services_t;
243+
244+
inline uint32_t GenerateDriverInterfaceVersion(uint16_t common_version, uint16_t specific_version)
245+
{
246+
return (common_version << 16) | specific_version;
247+
}
248+
249+
}
250+
#endif

0 commit comments

Comments
 (0)