1 /*
2  * Copyright (C) 2019-2021 Intel Corporation
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  */
7 
8 #include "patchtokens_dumper.h"
9 
10 #include "patchtokens_decoder.h"
11 
12 #include <sstream>
13 
14 namespace NEO {
15 
16 namespace PatchTokenBinary {
17 
18 #define CASE_TOK_STR(TOK)                              \
19     case TOK:                                          \
20         return std::to_string(TOK) + "(" + #TOK + ")"; \
21         break;
22 
asString(PATCH_TOKEN token)23 std::string asString(PATCH_TOKEN token) {
24     switch (token) {
25     default:
26         return std::to_string(token);
27         CASE_TOK_STR(PATCH_TOKEN_UNKNOWN);
28         CASE_TOK_STR(PATCH_TOKEN_MEDIA_STATE_POINTERS);
29         CASE_TOK_STR(PATCH_TOKEN_STATE_SIP);
30         CASE_TOK_STR(PATCH_TOKEN_CS_URB_STATE);
31         CASE_TOK_STR(PATCH_TOKEN_CONSTANT_BUFFER);
32         CASE_TOK_STR(PATCH_TOKEN_SAMPLER_STATE_ARRAY);
33         CASE_TOK_STR(PATCH_TOKEN_INTERFACE_DESCRIPTOR);
34         CASE_TOK_STR(PATCH_TOKEN_VFE_STATE);
35         CASE_TOK_STR(PATCH_TOKEN_BINDING_TABLE_STATE);
36         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_SCRATCH_SURFACE);
37         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_SIP_SURFACE);
38         CASE_TOK_STR(PATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT);
39         CASE_TOK_STR(PATCH_TOKEN_IMAGE_MEMORY_OBJECT_KERNEL_ARGUMENT);
40         CASE_TOK_STR(PATCH_TOKEN_CONSTANT_MEMORY_OBJECT_KERNEL_ARGUMENT);
41         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_SURFACE_WITH_INITIALIZATION);
42         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_LOCAL_SURFACE);
43         CASE_TOK_STR(PATCH_TOKEN_SAMPLER_KERNEL_ARGUMENT);
44         CASE_TOK_STR(PATCH_TOKEN_DATA_PARAMETER_BUFFER);
45         CASE_TOK_STR(PATCH_TOKEN_MEDIA_VFE_STATE);
46         CASE_TOK_STR(PATCH_TOKEN_MEDIA_INTERFACE_DESCRIPTOR_LOAD);
47         CASE_TOK_STR(PATCH_TOKEN_MEDIA_CURBE_LOAD);
48         CASE_TOK_STR(PATCH_TOKEN_INTERFACE_DESCRIPTOR_DATA);
49         CASE_TOK_STR(PATCH_TOKEN_THREAD_PAYLOAD);
50         CASE_TOK_STR(PATCH_TOKEN_EXECUTION_ENVIRONMENT);
51         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_PRIVATE_MEMORY);
52         CASE_TOK_STR(PATCH_TOKEN_DATA_PARAMETER_STREAM);
53         CASE_TOK_STR(PATCH_TOKEN_KERNEL_ARGUMENT_INFO);
54         CASE_TOK_STR(PATCH_TOKEN_KERNEL_ATTRIBUTES_INFO);
55         CASE_TOK_STR(PATCH_TOKEN_STRING);
56         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_PRINTF_SURFACE);
57         CASE_TOK_STR(PATCH_TOKEN_STATELESS_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT);
58         CASE_TOK_STR(PATCH_TOKEN_STATELESS_CONSTANT_MEMORY_OBJECT_KERNEL_ARGUMENT);
59         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_SURFACE_WITH_INITIALIZATION);
60         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_PRINTF_SURFACE);
61         CASE_TOK_STR(PATCH_TOKEN_CB_MAPPING);
62         CASE_TOK_STR(PATCH_TOKEN_CB2CR_GATHER_TABLE);
63         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_EVENT_POOL_SURFACE);
64         CASE_TOK_STR(PATCH_TOKEN_NULL_SURFACE_LOCATION);
65         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_PRIVATE_MEMORY);
66         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_WITH_INITIALIZATION);
67         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_WITH_INITIALIZATION);
68         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_GLOBAL_MEMORY_SURFACE_PROGRAM_BINARY_INFO);
69         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_CONSTANT_MEMORY_SURFACE_PROGRAM_BINARY_INFO);
70         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_GLOBAL_MEMORY_SURFACE_WITH_INITIALIZATION);
71         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_CONSTANT_MEMORY_SURFACE_WITH_INITIALIZATION);
72         CASE_TOK_STR(PATCH_TOKEN_ALLOCATE_STATELESS_DEFAULT_DEVICE_QUEUE_SURFACE);
73         CASE_TOK_STR(PATCH_TOKEN_STATELESS_DEVICE_QUEUE_KERNEL_ARGUMENT);
74         CASE_TOK_STR(PATCH_TOKEN_GLOBAL_POINTER_PROGRAM_BINARY_INFO);
75         CASE_TOK_STR(PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO);
76         CASE_TOK_STR(PATCH_TOKEN_CONSTRUCTOR_DESTRUCTOR_KERNEL_PROGRAM_BINARY_INFO);
77         CASE_TOK_STR(PATCH_TOKEN_INLINE_VME_SAMPLER_INFO);
78         CASE_TOK_STR(PATCH_TOKEN_GTPIN_FREE_GRF_INFO);
79         CASE_TOK_STR(PATCH_TOKEN_GTPIN_INFO);
80         CASE_TOK_STR(PATCH_TOKEN_PROGRAM_SYMBOL_TABLE);
81         CASE_TOK_STR(PATCH_TOKEN_PROGRAM_RELOCATION_TABLE);
82         CASE_TOK_STR(PATCH_TOKEN_MEDIA_VFE_STATE_SLOT1);
83     }
84 }
85 
asString(DATA_PARAMETER_TOKEN dataParameter)86 std::string asString(DATA_PARAMETER_TOKEN dataParameter) {
87     switch (dataParameter) {
88     default:
89         return std::to_string(dataParameter);
90         CASE_TOK_STR(DATA_PARAMETER_TOKEN_UNKNOWN);
91         CASE_TOK_STR(DATA_PARAMETER_KERNEL_ARGUMENT);
92         CASE_TOK_STR(DATA_PARAMETER_LOCAL_WORK_SIZE);
93         CASE_TOK_STR(DATA_PARAMETER_GLOBAL_WORK_SIZE);
94         CASE_TOK_STR(DATA_PARAMETER_NUM_WORK_GROUPS);
95         CASE_TOK_STR(DATA_PARAMETER_WORK_DIMENSIONS);
96         CASE_TOK_STR(DATA_PARAMETER_LOCAL_ID);
97         CASE_TOK_STR(DATA_PARAMETER_EXECUTION_MASK);
98         CASE_TOK_STR(DATA_PARAMETER_SUM_OF_LOCAL_MEMORY_OBJECT_ARGUMENT_SIZES);
99         CASE_TOK_STR(DATA_PARAMETER_IMAGE_WIDTH);
100         CASE_TOK_STR(DATA_PARAMETER_IMAGE_HEIGHT);
101         CASE_TOK_STR(DATA_PARAMETER_IMAGE_DEPTH);
102         CASE_TOK_STR(DATA_PARAMETER_IMAGE_CHANNEL_DATA_TYPE);
103         CASE_TOK_STR(DATA_PARAMETER_IMAGE_CHANNEL_ORDER);
104         CASE_TOK_STR(DATA_PARAMETER_FLAT_IMAGE_BASEOFFSET);
105         CASE_TOK_STR(DATA_PARAMETER_FLAT_IMAGE_WIDTH);
106         CASE_TOK_STR(DATA_PARAMETER_FLAT_IMAGE_HEIGHT);
107         CASE_TOK_STR(DATA_PARAMETER_FLAT_IMAGE_PITCH);
108         CASE_TOK_STR(DATA_PARAMETER_SAMPLER_ADDRESS_MODE);
109         CASE_TOK_STR(DATA_PARAMETER_SAMPLER_NORMALIZED_COORDS);
110         CASE_TOK_STR(DATA_PARAMETER_GLOBAL_WORK_OFFSET);
111         CASE_TOK_STR(DATA_PARAMETER_NUM_HARDWARE_THREADS);
112         CASE_TOK_STR(DATA_PARAMETER_IMAGE_ARRAY_SIZE);
113         CASE_TOK_STR(DATA_PARAMETER_PRINTF_SURFACE_SIZE);
114         CASE_TOK_STR(DATA_PARAMETER_IMAGE_NUM_SAMPLES);
115         CASE_TOK_STR(DATA_PARAMETER_SAMPLER_COORDINATE_SNAP_WA_REQUIRED);
116         CASE_TOK_STR(DATA_PARAMETER_PARENT_EVENT);
117         CASE_TOK_STR(DATA_PARAMETER_VME_MB_BLOCK_TYPE);
118         CASE_TOK_STR(DATA_PARAMETER_VME_SUBPIXEL_MODE);
119         CASE_TOK_STR(DATA_PARAMETER_VME_SAD_ADJUST_MODE);
120         CASE_TOK_STR(DATA_PARAMETER_VME_SEARCH_PATH_TYPE);
121         CASE_TOK_STR(DATA_PARAMETER_IMAGE_NUM_MIP_LEVELS);
122         CASE_TOK_STR(DATA_PARAMETER_ENQUEUED_LOCAL_WORK_SIZE);
123         CASE_TOK_STR(DATA_PARAMETER_MAX_WORKGROUP_SIZE);
124         CASE_TOK_STR(DATA_PARAMETER_PREFERRED_WORKGROUP_MULTIPLE);
125         CASE_TOK_STR(DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_START_ADDRESS);
126         CASE_TOK_STR(DATA_PARAMETER_LOCAL_MEMORY_STATELESS_WINDOW_SIZE);
127         CASE_TOK_STR(DATA_PARAMETER_PRIVATE_MEMORY_STATELESS_SIZE);
128         CASE_TOK_STR(DATA_PARAMETER_SIMD_SIZE);
129         CASE_TOK_STR(DATA_PARAMETER_OBJECT_ID);
130         CASE_TOK_STR(DATA_PARAMETER_VME_IMAGE_TYPE);
131         CASE_TOK_STR(DATA_PARAMETER_VME_MB_SKIP_BLOCK_TYPE);
132         CASE_TOK_STR(DATA_PARAMETER_CHILD_BLOCK_SIMD_SIZE);
133         CASE_TOK_STR(DATA_PARAMETER_IMAGE_SRGB_CHANNEL_ORDER);
134         CASE_TOK_STR(DATA_PARAMETER_STAGE_IN_GRID_ORIGIN);
135         CASE_TOK_STR(DATA_PARAMETER_STAGE_IN_GRID_SIZE);
136         CASE_TOK_STR(DATA_PARAMETER_BUFFER_OFFSET);
137         CASE_TOK_STR(DATA_PARAMETER_BUFFER_STATEFUL);
138     }
139 }
140 #undef CASE_TOK_STR
141 
dump(const SProgramBinaryHeader & value,std::stringstream & out,const std::string & indent)142 void dump(const SProgramBinaryHeader &value, std::stringstream &out, const std::string &indent) {
143     out << indent << "struct SProgramBinaryHeader {\n";
144     out << indent << "    uint32_t   Magic; // = " << value.Magic << "\n";
145     out << indent << "    uint32_t   Version; // = " << value.Version << "\n";
146     out << indent << "\n";
147     out << indent << "    uint32_t   Device; // = " << value.Device << "\n";
148     out << indent << "    uint32_t   GPUPointerSizeInBytes; // = " << value.GPUPointerSizeInBytes << "\n";
149     out << indent << "\n";
150     out << indent << "    uint32_t   NumberOfKernels; // = " << value.NumberOfKernels << "\n";
151     out << indent << "\n";
152     out << indent << "    uint32_t   SteppingId; // = " << value.SteppingId << "\n";
153     out << indent << "\n";
154     out << indent << "    uint32_t   PatchListSize; // = " << value.PatchListSize << "\n";
155     out << indent << "};\n";
156 }
157 
dump(const SKernelBinaryHeader & value,std::stringstream & out,const std::string & indent)158 void dump(const SKernelBinaryHeader &value, std::stringstream &out, const std::string &indent) {
159     out << indent << "struct SKernelBinaryHeader {\n";
160     out << indent << "    uint32_t   CheckSum;// = " << value.CheckSum << "\n";
161     out << indent << "    uint64_t   ShaderHashCode;// = " << value.ShaderHashCode << "\n";
162     out << indent << "    uint32_t   KernelNameSize;// = " << value.KernelNameSize << "\n";
163     out << indent << "    uint32_t   PatchListSize;// = " << value.PatchListSize << "\n";
164     out << indent << "};\n";
165 }
166 
167 void dump(const SPatchDataParameterBuffer &value, std::stringstream &out, const std::string &indent);
dump(const SPatchItemHeader & value,std::stringstream & out,const std::string & indent)168 void dump(const SPatchItemHeader &value, std::stringstream &out, const std::string &indent) {
169     if (value.Token == iOpenCL::PATCH_TOKEN_DATA_PARAMETER_BUFFER) {
170         dump(static_cast<const SPatchDataParameterBuffer &>(value), out, indent);
171         return;
172     }
173     out << indent << "struct SPatchItemHeader {\n";
174     out << indent << "    uint32_t   Token;// = " << asString(static_cast<PATCH_TOKEN>(value.Token)) << "\n";
175     out << indent << "    uint32_t   Size;// = " << value.Size << "\n";
176     out << indent << "};\n";
177 }
178 
dumpPatchItemHeaderInline(const SPatchItemHeader & value,std::stringstream & out,const std::string & indent)179 void dumpPatchItemHeaderInline(const SPatchItemHeader &value, std::stringstream &out, const std::string &indent) {
180     out << "Token=" << asString(static_cast<PATCH_TOKEN>(value.Token)) << ", Size=" << value.Size;
181 }
182 
dump(const SPatchGlobalMemoryObjectKernelArgument & value,std::stringstream & out,const std::string & indent)183 void dump(const SPatchGlobalMemoryObjectKernelArgument &value, std::stringstream &out, const std::string &indent) {
184     out << indent << "struct SPatchGlobalMemoryObjectKernelArgument :\n";
185     out << indent << "       SPatchItemHeader (";
186     dumpPatchItemHeaderInline(value, out, "");
187     out << ")\n"
188         << indent << "{\n";
189     out << indent << "    uint32_t   ArgumentNumber;// = " << value.ArgumentNumber << "\n";
190     out << indent << "    uint32_t   Offset;// = " << value.Offset << "\n";
191     out << indent << "    uint32_t   LocationIndex;// = " << value.LocationIndex << "\n";
192     out << indent << "    uint32_t   LocationIndex2;// = " << value.LocationIndex2 << "\n";
193     out << indent << "    uint32_t   IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
194     out << indent << "}\n";
195 }
196 
dump(const SPatchImageMemoryObjectKernelArgument & value,std::stringstream & out,const std::string & indent)197 void dump(const SPatchImageMemoryObjectKernelArgument &value, std::stringstream &out, const std::string &indent) {
198     out << indent << "struct SPatchImageMemoryObjectKernelArgument :\n";
199     out << indent << "       SPatchItemHeader (";
200     dumpPatchItemHeaderInline(value, out, "");
201     out << ")\n"
202         << indent << "{\n";
203     out << indent << "    uint32_t  ArgumentNumber;// = " << value.ArgumentNumber << "\n";
204     out << indent << "    uint32_t  Type;// = " << value.Type << "\n";
205     out << indent << "    uint32_t  Offset;// = " << value.Offset << "\n";
206     out << indent << "    uint32_t  LocationIndex;// = " << value.LocationIndex << "\n";
207     out << indent << "    uint32_t  LocationIndex2;// = " << value.LocationIndex2 << "\n";
208     out << indent << "    uint32_t  Writeable;// = " << value.Writeable << "\n";
209     out << indent << "    uint32_t  Transformable;// = " << value.Transformable << "\n";
210     out << indent << "    uint32_t  needBindlessHandle;// = " << value.needBindlessHandle << "\n";
211     out << indent << "    uint32_t  IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
212     out << indent << "    uint32_t  btiOffset;// = " << value.btiOffset << "\n";
213     out << indent << "}\n";
214 }
215 
dump(const SPatchSamplerKernelArgument & value,std::stringstream & out,const std::string & indent)216 void dump(const SPatchSamplerKernelArgument &value, std::stringstream &out, const std::string &indent) {
217     out << indent << "struct SPatchSamplerKernelArgument :\n";
218     out << indent << "       SPatchItemHeader (";
219     dumpPatchItemHeaderInline(value, out, "");
220     out << ")\n"
221         << indent << "{\n";
222     out << indent << "    uint32_t   ArgumentNumber;// = " << value.ArgumentNumber << "\n";
223     out << indent << "    uint32_t   Type;// = " << value.Type << "\n";
224     out << indent << "    uint32_t   Offset;// = " << value.Offset << "\n";
225     out << indent << "    uint32_t   LocationIndex;// = " << value.LocationIndex << "\n";
226     out << indent << "    uint32_t   LocationIndex2;// = " << value.LocationIndex2 << "\n";
227     out << indent << "    uint32_t   needBindlessHandle;// = " << value.needBindlessHandle << "\n";
228     out << indent << "    uint32_t   TextureMask;// = " << value.TextureMask << "\n";
229     out << indent << "    uint32_t   IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
230     out << indent << "    uint32_t   btiOffset;// = " << value.btiOffset << "\n";
231     out << indent << "}\n";
232 }
233 
dump(const SPatchDataParameterBuffer & value,std::stringstream & out,const std::string & indent)234 void dump(const SPatchDataParameterBuffer &value, std::stringstream &out, const std::string &indent) {
235     out << indent << "struct SPatchDataParameterBuffer :\n";
236     out << indent << "       SPatchItemHeader (";
237     dumpPatchItemHeaderInline(value, out, "");
238     out << ")\n"
239         << indent << "{\n";
240     out << indent << "    uint32_t   Type;// = " << asString(static_cast<DATA_PARAMETER_TOKEN>(value.Type)) << "\n";
241     out << indent << "    uint32_t   ArgumentNumber;// = " << value.ArgumentNumber << "\n";
242     out << indent << "    uint32_t   Offset;// = " << value.Offset << "\n";
243     out << indent << "    uint32_t   DataSize;// = " << value.DataSize << "\n";
244     out << indent << "    uint32_t   SourceOffset;// = " << value.SourceOffset << "\n";
245     out << indent << "    uint32_t   LocationIndex;// = " << value.LocationIndex << "\n";
246     out << indent << "    uint32_t   LocationIndex2;// = " << value.LocationIndex2 << "\n";
247     out << indent << "    uint32_t   IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
248     out << indent << "}\n";
249 }
250 
dump(const SPatchKernelArgumentInfo & value,std::stringstream & out,const std::string & indent)251 void dump(const SPatchKernelArgumentInfo &value, std::stringstream &out, const std::string &indent) {
252     auto toStr = [](ArrayRef<const char> &src) { return std::string(src.begin(), src.end()); };
253     auto inlineData = getInlineData(&value);
254     out << indent << "struct SPatchKernelArgumentInfo :\n";
255     out << indent << "       SPatchItemHeader (";
256     dumpPatchItemHeaderInline(value, out, "");
257     out << ")\n"
258         << indent << "{\n";
259     out << indent << "    uint32_t ArgumentNumber;// = " << value.ArgumentNumber << "\n";
260     out << indent << "    uint32_t AddressQualifierSize;// = " << value.AddressQualifierSize << " : [" << toStr(inlineData.addressQualifier) << "]\n";
261     out << indent << "    uint32_t AccessQualifierSize;// = " << value.AccessQualifierSize << " : [" << toStr(inlineData.accessQualifier) << "]\n";
262     out << indent << "    uint32_t ArgumentNameSize;// = " << value.ArgumentNameSize << " : [" << toStr(inlineData.argName) << "]\n";
263     out << indent << "    uint32_t TypeNameSize;// = " << value.TypeNameSize << " : [" << toStr(inlineData.typeName) << "]\n";
264     out << indent << "    uint32_t TypeQualifierSize;// = " << value.TypeQualifierSize << " : [" << toStr(inlineData.typeQualifiers) << "]\n";
265     out << indent << "}\n";
266 }
267 
dump(const SPatchKernelAttributesInfo & value,std::stringstream & out,const std::string & indent)268 void dump(const SPatchKernelAttributesInfo &value, std::stringstream &out, const std::string &indent) {
269     out << indent << "struct SPatchKernelAttributesInfo :\n";
270     out << indent << "       SPatchItemHeader (";
271     dumpPatchItemHeaderInline(value, out, "");
272     out << ")\n"
273         << indent << "{\n";
274     out << indent << "    uint32_t AttributesSize;// = " << value.AttributesSize << "\n";
275     out << indent << "}\n";
276 }
277 
dump(const SPatchMediaInterfaceDescriptorLoad & value,std::stringstream & out,const std::string & indent)278 void dump(const SPatchMediaInterfaceDescriptorLoad &value, std::stringstream &out, const std::string &indent) {
279     out << indent << "struct SPatchMediaInterfaceDescriptorLoad :\n";
280     out << indent << "       SPatchItemHeader (";
281     dumpPatchItemHeaderInline(value, out, "");
282     out << ")\n"
283         << indent << "{\n";
284     out << indent << "    uint32_t   InterfaceDescriptorDataOffset;// = " << value.InterfaceDescriptorDataOffset << "\n";
285     out << indent << "}\n";
286 }
287 
dump(const SPatchInterfaceDescriptorData & value,std::stringstream & out,const std::string & indent)288 void dump(const SPatchInterfaceDescriptorData &value, std::stringstream &out, const std::string &indent) {
289     out << indent << "struct SPatchInterfaceDescriptorData :\n";
290     out << indent << "       SPatchItemHeader (";
291     dumpPatchItemHeaderInline(value, out, "");
292     out << ")\n"
293         << indent << "{\n";
294     out << indent << "    uint32_t   Offset;// = " << value.Offset << "\n";
295     out << indent << "    uint32_t   SamplerStateOffset;// = " << value.SamplerStateOffset << "\n";
296     out << indent << "    uint32_t   KernelOffset;// = " << value.KernelOffset << "\n";
297     out << indent << "    uint32_t   BindingTableOffset;// = " << value.BindingTableOffset << "\n";
298     out << indent << "}\n";
299 }
300 
dump(const SPatchDataParameterStream & value,std::stringstream & out,const std::string & indent)301 void dump(const SPatchDataParameterStream &value, std::stringstream &out, const std::string &indent) {
302     out << indent << "struct SPatchDataParameterStream :\n";
303     out << indent << "       SPatchItemHeader (";
304     dumpPatchItemHeaderInline(value, out, "");
305     out << ")\n"
306         << indent << "{\n";
307     out << indent << "    uint32_t   DataParameterStreamSize;// = " << value.DataParameterStreamSize << "\n";
308     out << indent << "}\n";
309 }
310 
dump(const SPatchStateSIP & value,std::stringstream & out,const std::string & indent)311 void dump(const SPatchStateSIP &value, std::stringstream &out, const std::string &indent) {
312     out << indent << "struct SPatchStateSIP :\n";
313     out << indent << "       SPatchItemHeader (";
314     dumpPatchItemHeaderInline(value, out, "");
315     out << ")\n"
316         << indent << "{\n";
317     out << indent << "    uint32_t   SystemKernelOffset;// = " << value.SystemKernelOffset << "\n";
318     out << indent << "}\n";
319 }
320 
dump(const SPatchSamplerStateArray & value,std::stringstream & out,const std::string & indent)321 void dump(const SPatchSamplerStateArray &value, std::stringstream &out, const std::string &indent) {
322     out << indent << "struct SPatchSamplerStateArray :\n";
323     out << indent << "       SPatchItemHeader (";
324     dumpPatchItemHeaderInline(value, out, "");
325     out << ")\n"
326         << indent << "{\n";
327     out << indent << "    uint32_t   Offset;// = " << value.Offset << "\n";
328     out << indent << "    uint32_t   Count;// = " << value.Count << "\n";
329     out << indent << "    uint32_t   BorderColorOffset;// = " << value.BorderColorOffset << "\n";
330     out << indent << "}\n";
331 }
332 
dump(const SPatchBindingTableState & value,std::stringstream & out,const std::string & indent)333 void dump(const SPatchBindingTableState &value, std::stringstream &out, const std::string &indent) {
334     out << indent << "struct SPatchBindingTableState :\n";
335     out << indent << "       SPatchItemHeader (";
336     dumpPatchItemHeaderInline(value, out, "");
337     out << ")\n"
338         << indent << "{\n";
339     out << indent << "    uint32_t   Offset;// = " << value.Offset << "\n";
340     out << indent << "    uint32_t   Count;// = " << value.Count << "\n";
341     out << indent << "    uint32_t   SurfaceStateOffset;// = " << value.SurfaceStateOffset << "\n";
342     out << indent << "}\n";
343 }
344 
dump(const SPatchAllocateSystemThreadSurface & value,std::stringstream & out,const std::string & indent)345 void dump(const SPatchAllocateSystemThreadSurface &value, std::stringstream &out, const std::string &indent) {
346     out << indent << "struct SPatchAllocateSystemThreadSurface :\n";
347     out << indent << "       SPatchItemHeader (";
348     dumpPatchItemHeaderInline(value, out, "");
349     out << ")\n"
350         << indent << "{\n";
351     out << indent << "    uint32_t   Offset;// = " << value.Offset << "\n";
352     out << indent << "    uint32_t   PerThreadSystemThreadSurfaceSize;// = " << value.PerThreadSystemThreadSurfaceSize << "\n";
353     out << indent << "    uint32_t   BTI;// = " << value.BTI << "\n";
354     out << indent << "}\n";
355 }
356 
dump(const SPatchAllocateLocalSurface & value,std::stringstream & out,const std::string & indent)357 void dump(const SPatchAllocateLocalSurface &value, std::stringstream &out, const std::string &indent) {
358     out << indent << "struct SPatchAllocateLocalSurface :\n";
359     out << indent << "       SPatchItemHeader (";
360     dumpPatchItemHeaderInline(value, out, "");
361     out << ")\n"
362         << indent << "{\n";
363     out << indent << "    uint32_t   Offset;// = " << value.Offset << "\n";
364     out << indent << "    uint32_t   TotalInlineLocalMemorySize;// = " << value.TotalInlineLocalMemorySize << "\n";
365     out << indent << "}\n";
366 }
367 
dump(const SPatchThreadPayload & value,std::stringstream & out,const std::string & indent)368 void dump(const SPatchThreadPayload &value, std::stringstream &out, const std::string &indent) {
369     out << indent << "struct SPatchThreadPayload :\n";
370     out << indent << "       SPatchItemHeader (";
371     dumpPatchItemHeaderInline(value, out, "");
372     out << ")\n"
373         << indent << "{\n";
374     out << indent << "    uint32_t    HeaderPresent;// = " << value.HeaderPresent << "\n";
375     out << indent << "    uint32_t    LocalIDXPresent;// = " << value.LocalIDXPresent << "\n";
376     out << indent << "    uint32_t    LocalIDYPresent;// = " << value.LocalIDYPresent << "\n";
377     out << indent << "    uint32_t    LocalIDZPresent;// = " << value.LocalIDZPresent << "\n";
378     out << indent << "    uint32_t    LocalIDFlattenedPresent;// = " << value.LocalIDFlattenedPresent << "\n";
379     out << indent << "    uint32_t    IndirectPayloadStorage;// = " << value.IndirectPayloadStorage << "\n";
380     out << indent << "    uint32_t    UnusedPerThreadConstantPresent;// = " << value.UnusedPerThreadConstantPresent << "\n";
381     out << indent << "    uint32_t    GetLocalIDPresent;// = " << value.GetLocalIDPresent << "\n";
382     out << indent << "    uint32_t    GetGroupIDPresent;// = " << value.GetGroupIDPresent << "\n";
383     out << indent << "    uint32_t    GetGlobalOffsetPresent;// = " << value.GetGlobalOffsetPresent << "\n";
384     out << indent << "    uint32_t    StageInGridOriginPresent;// = " << value.StageInGridOriginPresent << "\n";
385     out << indent << "    uint32_t    StageInGridSizePresent;// = " << value.StageInGridSizePresent << "\n";
386     out << indent << "    uint32_t    OffsetToSkipPerThreadDataLoad;// = " << value.OffsetToSkipPerThreadDataLoad << "\n";
387     out << indent << "    uint32_t    OffsetToSkipSetFFIDGP;// = " << value.OffsetToSkipSetFFIDGP << "\n";
388     out << indent << "    uint32_t    PassInlineData;// = " << value.PassInlineData << "\n";
389     out << indent << "}\n";
390 }
391 
dump(const SPatchExecutionEnvironment & value,std::stringstream & out,const std::string & indent)392 void dump(const SPatchExecutionEnvironment &value, std::stringstream &out, const std::string &indent) {
393     out << indent << "struct SPatchExecutionEnvironment :\n";
394     out << indent << "       SPatchItemHeader (";
395     dumpPatchItemHeaderInline(value, out, "");
396     out << ")\n"
397         << indent << "{\n";
398     out << indent << "    uint32_t    RequiredWorkGroupSizeX;// = " << value.RequiredWorkGroupSizeX << "\n";
399     out << indent << "    uint32_t    RequiredWorkGroupSizeY;// = " << value.RequiredWorkGroupSizeY << "\n";
400     out << indent << "    uint32_t    RequiredWorkGroupSizeZ;// = " << value.RequiredWorkGroupSizeZ << "\n";
401     out << indent << "    uint32_t    LargestCompiledSIMDSize;// = " << value.LargestCompiledSIMDSize << "\n";
402     out << indent << "    uint32_t    CompiledSubGroupsNumber;// = " << value.CompiledSubGroupsNumber << "\n";
403     out << indent << "    uint32_t    HasBarriers;// = " << value.HasBarriers << "\n";
404     out << indent << "    uint32_t    DisableMidThreadPreemption;// = " << value.DisableMidThreadPreemption << "\n";
405     out << indent << "    uint32_t    CompiledSIMD8;// = " << value.CompiledSIMD8 << "\n";
406     out << indent << "    uint32_t    CompiledSIMD16;// = " << value.CompiledSIMD16 << "\n";
407     out << indent << "    uint32_t    CompiledSIMD32;// = " << value.CompiledSIMD32 << "\n";
408     out << indent << "    uint32_t    HasDeviceEnqueue;// = " << value.HasDeviceEnqueue << "\n";
409     out << indent << "    uint32_t    MayAccessUndeclaredResource;// = " << value.MayAccessUndeclaredResource << "\n";
410     out << indent << "    uint32_t    UsesFencesForReadWriteImages;// = " << value.UsesFencesForReadWriteImages << "\n";
411     out << indent << "    uint32_t    UsesStatelessSpillFill;// = " << value.UsesStatelessSpillFill << "\n";
412     out << indent << "    uint32_t    UsesMultiScratchSpaces;// = " << value.UsesMultiScratchSpaces << "\n";
413     out << indent << "    uint32_t    IsCoherent;// = " << value.IsCoherent << "\n";
414     out << indent << "    uint32_t    IsInitializer;// = " << value.IsInitializer << "\n";
415     out << indent << "    uint32_t    IsFinalizer;// = " << value.IsFinalizer << "\n";
416     out << indent << "    uint32_t    SubgroupIndependentForwardProgressRequired;// = " << value.SubgroupIndependentForwardProgressRequired << "\n";
417     out << indent << "    uint32_t    CompiledForGreaterThan4GBBuffers;// = " << value.CompiledForGreaterThan4GBBuffers << "\n";
418     out << indent << "    uint32_t    NumGRFRequired;// = " << value.NumGRFRequired << "\n";
419     out << indent << "    uint32_t    WorkgroupWalkOrderDims;// = " << value.WorkgroupWalkOrderDims << "\n";
420     out << indent << "    uint32_t    HasGlobalAtomics;// = " << value.HasGlobalAtomics << "\n";
421     out << indent << "    uint32_t    HasStackCalls;// = " << value.HasStackCalls << "\n";
422     out << indent << "}\n";
423 }
424 
dump(const SPatchString & value,std::stringstream & out,const std::string & indent)425 void dump(const SPatchString &value, std::stringstream &out, const std::string &indent) {
426     const char *strBeg = reinterpret_cast<const char *>((&value) + 1);
427     std::string strValue = std::string(strBeg, strBeg + value.StringSize);
428     out << indent << "struct SPatchString :\n";
429     out << indent << "       SPatchItemHeader (";
430     dumpPatchItemHeaderInline(value, out, "");
431     out << ")\n"
432         << indent << "{\n";
433     out << indent << "    uint32_t   Index;// = " << value.Index << "\n";
434     out << indent << "    uint32_t   StringSize;// = " << value.StringSize << " : [" << strValue << "]"
435         << "\n";
436     out << indent << "}\n";
437 }
438 
dump(const SPatchStatelessGlobalMemoryObjectKernelArgument & value,std::stringstream & out,const std::string & indent)439 void dump(const SPatchStatelessGlobalMemoryObjectKernelArgument &value, std::stringstream &out, const std::string &indent) {
440     out << indent << "struct SPatchStatelessGlobalMemoryObjectKernelArgument :\n";
441     out << indent << "       SPatchItemHeader (";
442     dumpPatchItemHeaderInline(value, out, "");
443     out << ")\n"
444         << indent << "{\n";
445     out << indent << "    uint32_t   ArgumentNumber;// = " << value.ArgumentNumber << "\n";
446     out << indent << "    uint32_t   SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
447     out << indent << "    uint32_t   DataParamOffset;// = " << value.DataParamOffset << "\n";
448     out << indent << "    uint32_t   DataParamSize;// = " << value.DataParamSize << "\n";
449     out << indent << "    uint32_t   LocationIndex;// = " << value.LocationIndex << "\n";
450     out << indent << "    uint32_t   LocationIndex2;// = " << value.LocationIndex2 << "\n";
451     out << indent << "    uint32_t   IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
452     out << indent << "}\n";
453 }
454 
dump(const SPatchStatelessConstantMemoryObjectKernelArgument & value,std::stringstream & out,const std::string & indent)455 void dump(const SPatchStatelessConstantMemoryObjectKernelArgument &value, std::stringstream &out, const std::string &indent) {
456     out << indent << "struct SPatchStatelessConstantMemoryObjectKernelArgument :\n";
457     out << indent << "       SPatchItemHeader (";
458     dumpPatchItemHeaderInline(value, out, "");
459     out << ")\n"
460         << indent << "{\n";
461     out << indent << "    uint32_t   ArgumentNumber;// = " << value.ArgumentNumber << "\n";
462     out << indent << "    uint32_t   SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
463     out << indent << "    uint32_t   DataParamOffset;// = " << value.DataParamOffset << "\n";
464     out << indent << "    uint32_t   DataParamSize;// = " << value.DataParamSize << "\n";
465     out << indent << "    uint32_t   LocationIndex;// = " << value.LocationIndex << "\n";
466     out << indent << "    uint32_t   LocationIndex2;// = " << value.LocationIndex2 << "\n";
467     out << indent << "    uint32_t   IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
468     out << indent << "}\n";
469 }
470 
dump(const SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization & value,std::stringstream & out,const std::string & indent)471 void dump(const SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization &value, std::stringstream &out, const std::string &indent) {
472     out << indent << "struct SPatchAllocateStatelessGlobalMemorySurfaceWithInitialization :\n";
473     out << indent << "       SPatchItemHeader (";
474     dumpPatchItemHeaderInline(value, out, "");
475     out << ")\n"
476         << indent << "{\n";
477     out << indent << "    uint32_t   GlobalBufferIndex;// = " << value.GlobalBufferIndex << "\n";
478     out << indent << "    uint32_t   SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
479     out << indent << "    uint32_t   DataParamOffset;// = " << value.DataParamOffset << "\n";
480     out << indent << "    uint32_t   DataParamSize;// = " << value.DataParamSize << "\n";
481     out << indent << "}\n";
482 }
483 
dump(const SPatchAllocateStatelessConstantMemorySurfaceWithInitialization & value,std::stringstream & out,const std::string & indent)484 void dump(const SPatchAllocateStatelessConstantMemorySurfaceWithInitialization &value, std::stringstream &out, const std::string &indent) {
485     out << indent << "struct SPatchAllocateStatelessConstantMemorySurfaceWithInitialization :\n";
486     out << indent << "       SPatchItemHeader (";
487     dumpPatchItemHeaderInline(value, out, "");
488     out << ")\n"
489         << indent << "{\n";
490     out << indent << "    uint32_t   ConstantBufferIndex;// = " << value.ConstantBufferIndex << "\n";
491     out << indent << "    uint32_t   SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
492     out << indent << "    uint32_t   DataParamOffset;// = " << value.DataParamOffset << "\n";
493     out << indent << "    uint32_t   DataParamSize;// = " << value.DataParamSize << "\n";
494     out << indent << "}\n";
495 }
496 
dump(const SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo & value,std::stringstream & out,const std::string & indent)497 void dump(const SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo &value, std::stringstream &out, const std::string &indent) {
498     out << indent << "struct SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo :\n";
499     out << indent << "       SPatchItemHeader (";
500     dumpPatchItemHeaderInline(value, out, "");
501     out << ")\n"
502         << indent << "{\n";
503     out << indent << "    uint32_t   Type;// = " << value.Type << "\n";
504     out << indent << "    uint32_t   GlobalBufferIndex;// = " << value.GlobalBufferIndex << "\n";
505     out << indent << "    uint32_t   InlineDataSize;// = " << value.InlineDataSize << "\n";
506     out << indent << "}\n";
507 }
508 
dump(const SPatchAllocateConstantMemorySurfaceProgramBinaryInfo & value,std::stringstream & out,const std::string & indent)509 void dump(const SPatchAllocateConstantMemorySurfaceProgramBinaryInfo &value, std::stringstream &out, const std::string &indent) {
510     out << indent << "struct SPatchAllocateConstantMemorySurfaceProgramBinaryInfo :\n";
511     out << indent << "       SPatchItemHeader (";
512     dumpPatchItemHeaderInline(value, out, "");
513     out << ")\n"
514         << indent << "{\n";
515     out << indent << "    uint32_t   ConstantBufferIndex;// = " << value.ConstantBufferIndex << "\n";
516     out << indent << "    uint32_t   InlineDataSize;// = " << value.InlineDataSize << "\n";
517     out << indent << "}\n";
518 }
519 
dump(const SPatchGlobalPointerProgramBinaryInfo & value,std::stringstream & out,const std::string & indent)520 void dump(const SPatchGlobalPointerProgramBinaryInfo &value, std::stringstream &out, const std::string &indent) {
521     out << indent << "struct SPatchGlobalPointerProgramBinaryInfo :\n";
522     out << indent << "       SPatchItemHeader (";
523     dumpPatchItemHeaderInline(value, out, "");
524     out << ")\n"
525         << indent << "{\n";
526     out << indent << "    uint32_t   GlobalBufferIndex;// = " << value.GlobalBufferIndex << "\n";
527     out << indent << "    uint64_t   GlobalPointerOffset;// = " << value.GlobalPointerOffset << "\n";
528     out << indent << "    uint32_t   BufferType;// = " << value.BufferType << "\n";
529     out << indent << "    uint32_t   BufferIndex;// = " << value.BufferIndex << "\n";
530     out << indent << "}\n";
531 }
532 
dump(const SPatchConstantPointerProgramBinaryInfo & value,std::stringstream & out,const std::string & indent)533 void dump(const SPatchConstantPointerProgramBinaryInfo &value, std::stringstream &out, const std::string &indent) {
534     out << indent << "struct SPatchConstantPointerProgramBinaryInfo :\n";
535     out << indent << "       SPatchItemHeader (";
536     dumpPatchItemHeaderInline(value, out, "");
537     out << ")\n"
538         << indent << "{\n";
539     out << indent << "    uint32_t   ConstantBufferIndex;// = " << value.ConstantBufferIndex << "\n";
540     out << indent << "    uint64_t   ConstantPointerOffset;// = " << value.ConstantPointerOffset << "\n";
541     out << indent << "    uint32_t   BufferType;// = " << value.BufferType << "\n";
542     out << indent << "    uint32_t   BufferIndex;// = " << value.BufferIndex << "\n";
543     out << indent << "}\n";
544 }
545 
dump(const SPatchAllocateStatelessPrintfSurface & value,std::stringstream & out,const std::string & indent)546 void dump(const SPatchAllocateStatelessPrintfSurface &value, std::stringstream &out, const std::string &indent) {
547     out << indent << "struct SPatchAllocateStatelessPrintfSurface :\n";
548     out << indent << "       SPatchItemHeader (";
549     dumpPatchItemHeaderInline(value, out, "");
550     out << ")\n"
551         << indent << "{\n";
552     out << indent << "    uint32_t   PrintfSurfaceIndex;// = " << value.PrintfSurfaceIndex << "\n";
553     out << indent << "    uint32_t   SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
554     out << indent << "    uint32_t   DataParamOffset;// = " << value.DataParamOffset << "\n";
555     out << indent << "    uint32_t   DataParamSize;// = " << value.DataParamSize << "\n";
556     out << indent << "}\n";
557 }
558 
dump(const SPatchAllocateStatelessPrivateSurface & value,std::stringstream & out,const std::string & indent)559 void dump(const SPatchAllocateStatelessPrivateSurface &value, std::stringstream &out, const std::string &indent) {
560     out << indent << "struct SPatchAllocateStatelessPrivateSurface :\n";
561     out << indent << "       SPatchItemHeader (";
562     dumpPatchItemHeaderInline(value, out, "");
563     out << ")\n"
564         << indent << "{\n";
565     out << indent << "    uint32_t   SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
566     out << indent << "    uint32_t   DataParamOffset;// = " << value.DataParamOffset << "\n";
567     out << indent << "    uint32_t   DataParamSize;// = " << value.DataParamSize << "\n";
568     out << indent << "    uint32_t   PerThreadPrivateMemorySize;// = " << value.PerThreadPrivateMemorySize << "\n";
569     out << indent << "    uint32_t   IsSimtThread;// = " << value.IsSimtThread << "\n";
570     out << indent << "}\n";
571 }
572 
dump(const SPatchMediaVFEState & value,std::stringstream & out,const std::string & indent)573 void dump(const SPatchMediaVFEState &value, std::stringstream &out, const std::string &indent) {
574     out << indent << "struct SPatchMediaVFEState :\n";
575     out << indent << "       SPatchItemHeader (";
576     dumpPatchItemHeaderInline(value, out, "");
577     out << ")\n"
578         << indent << "{\n";
579     out << indent << "    uint32_t   ScratchSpaceOffset;// = " << value.ScratchSpaceOffset << "\n";
580     out << indent << "    uint32_t   PerThreadScratchSpace;// = " << value.PerThreadScratchSpace << "\n";
581     out << indent << "}\n";
582 }
583 
dump(const SPatchAllocateStatelessEventPoolSurface & value,std::stringstream & out,const std::string & indent)584 void dump(const SPatchAllocateStatelessEventPoolSurface &value, std::stringstream &out, const std::string &indent) {
585     out << indent << "struct SPatchAllocateStatelessEventPoolSurface :\n";
586     out << indent << "       SPatchItemHeader (";
587     dumpPatchItemHeaderInline(value, out, "");
588     out << ")\n"
589         << indent << "{\n";
590     out << indent << "    uint32_t   EventPoolSurfaceIndex;// = " << value.EventPoolSurfaceIndex << "\n";
591     out << indent << "    uint32_t   SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
592     out << indent << "    uint32_t   DataParamOffset;// = " << value.DataParamOffset << "\n";
593     out << indent << "    uint32_t   DataParamSize;// = " << value.DataParamSize << "\n";
594     out << indent << "}\n";
595 }
596 
dump(const SPatchAllocateStatelessDefaultDeviceQueueSurface & value,std::stringstream & out,const std::string & indent)597 void dump(const SPatchAllocateStatelessDefaultDeviceQueueSurface &value, std::stringstream &out, const std::string &indent) {
598     out << indent << "struct SPatchAllocateStatelessDefaultDeviceQueueSurface :\n";
599     out << indent << "       SPatchItemHeader (";
600     dumpPatchItemHeaderInline(value, out, "");
601     out << ")\n"
602         << indent << "{\n";
603     out << indent << "    uint32_t   SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
604     out << indent << "    uint32_t   DataParamOffset;// = " << value.DataParamOffset << "\n";
605     out << indent << "    uint32_t   DataParamSize;// = " << value.DataParamSize << "\n";
606     out << indent << "}\n";
607 }
608 
dump(const SPatchStatelessDeviceQueueKernelArgument & value,std::stringstream & out,const std::string & indent)609 void dump(const SPatchStatelessDeviceQueueKernelArgument &value, std::stringstream &out, const std::string &indent) {
610     out << indent << "struct SPatchStatelessDeviceQueueKernelArgument :\n";
611     out << indent << "       SPatchItemHeader (";
612     dumpPatchItemHeaderInline(value, out, "");
613     out << ")\n"
614         << indent << "{\n";
615     out << indent << "    uint32_t   ArgumentNumber;// = " << value.ArgumentNumber << "\n";
616     out << indent << "    uint32_t   SurfaceStateHeapOffset;// = " << value.SurfaceStateHeapOffset << "\n";
617     out << indent << "    uint32_t   DataParamOffset;// = " << value.DataParamOffset << "\n";
618     out << indent << "    uint32_t   DataParamSize;// = " << value.DataParamSize << "\n";
619     out << indent << "    uint32_t   LocationIndex;// = " << value.LocationIndex << "\n";
620     out << indent << "    uint32_t   LocationIndex2;// = " << value.LocationIndex2 << "\n";
621     out << indent << "    uint32_t   IsEmulationArgument;// = " << value.IsEmulationArgument << "\n";
622     out << indent << "}\n";
623 }
624 
dump(const SPatchGtpinFreeGRFInfo & value,std::stringstream & out,const std::string & indent)625 void dump(const SPatchGtpinFreeGRFInfo &value, std::stringstream &out, const std::string &indent) {
626     out << indent << "struct SPatchGtpinFreeGRFInfo :\n";
627     out << indent << "       SPatchItemHeader (";
628     dumpPatchItemHeaderInline(value, out, "");
629     out << ")\n"
630         << indent << "{\n";
631     out << indent << "    uint32_t   BufferSize;// = " << value.BufferSize << "\n";
632     out << indent << "}\n";
633 }
634 
dump(const SPatchFunctionTableInfo & value,std::stringstream & out,const std::string & indent)635 void dump(const SPatchFunctionTableInfo &value, std::stringstream &out, const std::string &indent) {
636     out << indent << "struct SPatchFunctionTableInfo :\n";
637     out << indent << "       SPatchItemHeader (";
638     dumpPatchItemHeaderInline(value, out, "");
639     out << ")\n"
640         << indent << "{\n";
641     out << indent << "    uint32_t   NumEntries;// = " << value.NumEntries << "\n";
642     out << indent << "}\n";
643 }
644 
645 template <typename T>
dumpOrNull(const T * value,const std::string & messageIfNull,std::stringstream & out,const std::string & indent)646 void dumpOrNull(const T *value, const std::string &messageIfNull, std::stringstream &out, const std::string &indent) {
647     if (value == nullptr) {
648         if (messageIfNull.empty() == false) {
649             out << indent << messageIfNull;
650         }
651         return;
652     }
653     dump(*value, out, indent);
654 }
655 
656 template <typename T>
dumpOrNullObjArg(const T * value,std::stringstream & out,const std::string & indent)657 void dumpOrNullObjArg(const T *value, std::stringstream &out, const std::string &indent) {
658     if (value == nullptr) {
659         return;
660     }
661     switch (value->Token) {
662     default:
663         UNRECOVERABLE_IF(value->Token != PATCH_TOKEN_SAMPLER_KERNEL_ARGUMENT);
664         dumpOrNull(reinterpret_cast<const SPatchSamplerKernelArgument *>(value), "", out, indent);
665         break;
666     case PATCH_TOKEN_IMAGE_MEMORY_OBJECT_KERNEL_ARGUMENT:
667         dumpOrNull(reinterpret_cast<const SPatchImageMemoryObjectKernelArgument *>(value), "", out, indent);
668         break;
669     case PATCH_TOKEN_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
670         dumpOrNull(reinterpret_cast<const SPatchGlobalMemoryObjectKernelArgument *>(value), "", out, indent);
671         break;
672     case PATCH_TOKEN_STATELESS_GLOBAL_MEMORY_OBJECT_KERNEL_ARGUMENT:
673         dumpOrNull(reinterpret_cast<const SPatchStatelessGlobalMemoryObjectKernelArgument *>(value), "", out, indent);
674         break;
675     case PATCH_TOKEN_STATELESS_CONSTANT_MEMORY_OBJECT_KERNEL_ARGUMENT:
676         dumpOrNull(reinterpret_cast<const SPatchStatelessConstantMemoryObjectKernelArgument *>(value), "", out, indent);
677         break;
678     case PATCH_TOKEN_STATELESS_DEVICE_QUEUE_KERNEL_ARGUMENT:
679         dumpOrNull(reinterpret_cast<const SPatchStatelessDeviceQueueKernelArgument *>(value), "", out, indent);
680         break;
681     }
682 }
683 
684 template <typename T, size_t Size>
dumpOrNullArrayIfNotEmpty(T (& value)[Size],const std::string & arrayName,std::stringstream & out,const std::string & indent)685 void dumpOrNullArrayIfNotEmpty(T (&value)[Size], const std::string &arrayName, std::stringstream &out, const std::string &indent) {
686     bool allEmpty = true;
687     for (size_t i = 0; i < Size; ++i) {
688         allEmpty = allEmpty && (value[i] == nullptr);
689     }
690     if (allEmpty) {
691         return;
692     }
693     out << indent << arrayName << " [" << Size << "] :\n";
694     for (size_t i = 0; i < Size; ++i) {
695         if (value[i] == nullptr) {
696             continue;
697         }
698         out << indent << " + [" << i << "]:\n";
699         dump(*value[i], out, indent + " |  ");
700     }
701 }
702 
703 template <typename T>
dumpVecIfNotEmpty(const T & vector,const std::string & vectorName,std::stringstream & out,const std::string & indent)704 void dumpVecIfNotEmpty(const T &vector, const std::string &vectorName, std::stringstream &out, const std::string &indent) {
705     if (vector.size() == 0) {
706         return;
707     }
708     out << indent << vectorName << " [" << vector.size() << "] :\n";
709     for (size_t i = 0; i < vector.size(); ++i) {
710         out << indent << " + [" << i << "]:\n";
711         dumpOrNull(vector[i], "DECODER INTERNAL ERROR\n", out, indent + " |  ");
712     }
713 }
714 
asString(const ProgramFromPatchtokens & prog)715 std::string asString(const ProgramFromPatchtokens &prog) {
716     std::stringstream stream;
717     stream << "Program of size : " << prog.blobs.programInfo.size()
718            << " " << asString(prog.decodeStatus) << "\n";
719     dumpOrNull(prog.header, "WARNING : Program header is missing\n", stream, "");
720     stream << "Program-scope tokens section size : " << prog.blobs.patchList.size() << "\n";
721     dumpVecIfNotEmpty(prog.unhandledTokens, "WARNING : Unhandled program-scope tokens detected", stream, "  ");
722     dumpVecIfNotEmpty(prog.programScopeTokens.allocateConstantMemorySurface, "Inline Costant Surface(s)", stream, "  ");
723     dumpVecIfNotEmpty(prog.programScopeTokens.constantPointer, "Inline Costant Surface - self relocations", stream, "  ");
724     dumpVecIfNotEmpty(prog.programScopeTokens.allocateGlobalMemorySurface, "Inline Global Variable Surface(s)", stream, "  ");
725     dumpVecIfNotEmpty(prog.programScopeTokens.globalPointer, "Inline Global Variable Surface - self relocations", stream, "  ");
726     dumpOrNull(prog.programScopeTokens.symbolTable, "", stream, "  ");
727     stream << "Kernels section size : " << prog.blobs.kernelsInfo.size() << "\n";
728     for (size_t i = 0; i < prog.kernels.size(); ++i) {
729         stream << "kernel[" << i << "] " << (prog.kernels[i].name.size() > 0 ? std::string(prog.kernels[i].name.begin(), prog.kernels[i].name.end()).c_str() : "<UNNAMED>") << ":\n";
730         stream << asString(prog.kernels[i]);
731     }
732     return stream.str();
733 }
734 
asString(const KernelFromPatchtokens & kern)735 std::string asString(const KernelFromPatchtokens &kern) {
736     std::stringstream stream;
737     std::string indentLevel1 = "  ";
738     stream << "Kernel of size : " << kern.blobs.kernelInfo.size() << " "
739            << " " << asString(kern.decodeStatus) << "\n";
740     dumpOrNull(kern.header, "WARNING : Kernel header is missing\n", stream, "");
741     stream << "Kernel-scope tokens section size : " << kern.blobs.patchList.size() << "\n";
742     dumpVecIfNotEmpty(kern.unhandledTokens, "WARNING : Unhandled kernel-scope tokens detected", stream, indentLevel1);
743     dumpOrNull(kern.tokens.executionEnvironment, "", stream, indentLevel1);
744     dumpOrNull(kern.tokens.threadPayload, "", stream, indentLevel1);
745     dumpOrNull(kern.tokens.samplerStateArray, "", stream, indentLevel1);
746     dumpOrNull(kern.tokens.bindingTableState, "", stream, indentLevel1);
747     dumpOrNull(kern.tokens.allocateLocalSurface, "", stream, indentLevel1);
748     dumpOrNullArrayIfNotEmpty(kern.tokens.mediaVfeState, "mediaVfeState", stream, indentLevel1);
749     dumpOrNull(kern.tokens.mediaInterfaceDescriptorLoad, "", stream, indentLevel1);
750     dumpOrNull(kern.tokens.interfaceDescriptorData, "", stream, indentLevel1);
751     dumpOrNull(kern.tokens.kernelAttributesInfo, "", stream, indentLevel1);
752     dumpOrNull(kern.tokens.allocateStatelessPrivateSurface, "", stream, indentLevel1);
753     dumpOrNull(kern.tokens.allocateStatelessConstantMemorySurfaceWithInitialization, "", stream, indentLevel1);
754     dumpOrNull(kern.tokens.allocateStatelessGlobalMemorySurfaceWithInitialization, "", stream, indentLevel1);
755     dumpOrNull(kern.tokens.allocateStatelessPrintfSurface, "", stream, indentLevel1);
756     dumpOrNull(kern.tokens.allocateStatelessEventPoolSurface, "", stream, indentLevel1);
757     dumpOrNull(kern.tokens.allocateStatelessDefaultDeviceQueueSurface, "", stream, indentLevel1);
758     dumpOrNull(kern.tokens.inlineVmeSamplerInfo, "", stream, indentLevel1);
759     dumpOrNull(kern.tokens.gtpinFreeGrfInfo, "", stream, indentLevel1);
760     dumpOrNull(kern.tokens.stateSip, "", stream, indentLevel1);
761     dumpOrNull(kern.tokens.allocateSystemThreadSurface, "", stream, indentLevel1);
762     dumpOrNull(kern.tokens.gtpinInfo, "", stream, indentLevel1);
763     dumpOrNull(kern.tokens.programSymbolTable, "", stream, indentLevel1);
764     dumpOrNull(kern.tokens.programRelocationTable, "", stream, indentLevel1);
765     dumpOrNull(kern.tokens.dataParameterStream, "", stream, indentLevel1);
766     dumpVecIfNotEmpty(kern.tokens.strings, "String literals", stream, indentLevel1);
767     dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.localWorkSize, "localWorkSize", stream, indentLevel1);
768     dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.localWorkSize2, "localWorkSize2", stream, indentLevel1);
769     dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.enqueuedLocalWorkSize, "enqueuedLocalWorkSize", stream, indentLevel1);
770     dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.numWorkGroups, "numWorkGroups", stream, indentLevel1);
771     dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.globalWorkOffset, "globalWorkOffset", stream, indentLevel1);
772     dumpOrNullArrayIfNotEmpty(kern.tokens.crossThreadPayloadArgs.globalWorkSize, "globalWorkSize", stream, indentLevel1);
773     dumpOrNull(kern.tokens.crossThreadPayloadArgs.maxWorkGroupSize, "", stream, indentLevel1);
774     dumpOrNull(kern.tokens.crossThreadPayloadArgs.workDimensions, "", stream, indentLevel1);
775     dumpOrNull(kern.tokens.crossThreadPayloadArgs.simdSize, "", stream, indentLevel1);
776     dumpOrNull(kern.tokens.crossThreadPayloadArgs.parentEvent, "", stream, indentLevel1);
777     dumpOrNull(kern.tokens.crossThreadPayloadArgs.privateMemoryStatelessSize, "", stream, indentLevel1);
778     dumpOrNull(kern.tokens.crossThreadPayloadArgs.localMemoryStatelessWindowSize, "", stream, indentLevel1);
779     dumpOrNull(kern.tokens.crossThreadPayloadArgs.localMemoryStatelessWindowStartAddress, "", stream, indentLevel1);
780     dumpOrNull(kern.tokens.crossThreadPayloadArgs.preferredWorkgroupMultiple, "", stream, indentLevel1);
781     dumpVecIfNotEmpty(kern.tokens.crossThreadPayloadArgs.childBlockSimdSize, "Child block simd size(s)", stream, indentLevel1);
782 
783     if (kern.tokens.kernelArgs.size() != 0) {
784         stream << "Kernel arguments [" << kern.tokens.kernelArgs.size() << "] :\n";
785         for (size_t i = 0; i < kern.tokens.kernelArgs.size(); ++i) {
786             stream << "  + kernelArg[" << i << "]:\n";
787             stream << asString(kern.tokens.kernelArgs[i], indentLevel1 + "| ");
788         }
789     }
790     return stream.str();
791 }
792 
asString(ArgObjectType type,ArgObjectTypeSpecialized typeSpecialized)793 std::string asString(ArgObjectType type, ArgObjectTypeSpecialized typeSpecialized) {
794     std::string typeAsStr;
795     switch (type) {
796     default:
797         UNRECOVERABLE_IF(ArgObjectType::None != type);
798         return "unspecified";
799     case ArgObjectType::Buffer:
800         typeAsStr = "BUFFER";
801         break;
802     case ArgObjectType::Image:
803         typeAsStr = "IMAGE";
804         break;
805     case ArgObjectType::Sampler:
806         typeAsStr = "SAMPLER";
807         break;
808     case ArgObjectType::Slm:
809         typeAsStr = "SLM";
810         break;
811     }
812 
813     switch (typeSpecialized) {
814     default:
815         UNRECOVERABLE_IF(ArgObjectTypeSpecialized::None != typeSpecialized);
816         break;
817     case ArgObjectTypeSpecialized::Vme:
818         typeAsStr += " [ VME ]";
819     }
820 
821     return typeAsStr;
822 }
823 
asString(const KernelArgFromPatchtokens & arg,const std::string & indent)824 std::string asString(const KernelArgFromPatchtokens &arg, const std::string &indent) {
825     std::stringstream stream;
826     stream << indent << "Kernel argument of type " << asString(arg.objectType, arg.objectTypeSpecialized) << "\n";
827     std::string indentLevel1 = indent + "  ";
828     std::string indentLevel2 = indentLevel1 + "  ";
829     dumpOrNull(arg.argInfo, "", stream, indentLevel1);
830     dumpOrNullObjArg(arg.objectArg, stream, indentLevel1);
831     dumpOrNull(arg.objectId, "", stream, indentLevel1);
832     switch (arg.objectType) {
833     default:
834         break;
835     case ArgObjectType::Buffer:
836         stream << indentLevel1 << "Buffer Metadata:\n";
837         dumpOrNull(arg.metadata.buffer.bufferOffset, "", stream, indentLevel2);
838         dumpOrNull(arg.metadata.buffer.pureStateful, "", stream, indentLevel2);
839         break;
840     case ArgObjectType::Image:
841         stream << indentLevel1 << "Image Metadata:\n";
842         dumpOrNull(arg.metadata.image.width, "", stream, indentLevel2);
843         dumpOrNull(arg.metadata.image.height, "", stream, indentLevel2);
844         dumpOrNull(arg.metadata.image.depth, "", stream, indentLevel2);
845         dumpOrNull(arg.metadata.image.channelDataType, "", stream, indentLevel2);
846         dumpOrNull(arg.metadata.image.channelOrder, "", stream, indentLevel2);
847         dumpOrNull(arg.metadata.image.arraySize, "", stream, indentLevel2);
848         dumpOrNull(arg.metadata.image.numSamples, "", stream, indentLevel2);
849         dumpOrNull(arg.metadata.image.numMipLevels, "", stream, indentLevel2);
850         dumpOrNull(arg.metadata.image.flatBaseOffset, "", stream, indentLevel2);
851         dumpOrNull(arg.metadata.image.flatWidth, "", stream, indentLevel2);
852         dumpOrNull(arg.metadata.image.flatHeight, "", stream, indentLevel2);
853         dumpOrNull(arg.metadata.image.flatPitch, "", stream, indentLevel2);
854         break;
855     case ArgObjectType::Sampler:
856         stream << indentLevel1 << "Sampler Metadata:\n";
857         dumpOrNull(arg.metadata.sampler.addressMode, "", stream, indentLevel2);
858         dumpOrNull(arg.metadata.sampler.coordinateSnapWaRequired, "", stream, indentLevel2);
859         dumpOrNull(arg.metadata.sampler.normalizedCoords, "", stream, indentLevel2);
860         break;
861     case ArgObjectType::Slm:
862         stream << indentLevel1 << "Slm Metadata:\n";
863         dumpOrNull(arg.metadata.slm.token, "", stream, indentLevel2);
864         break;
865     }
866     switch (arg.objectTypeSpecialized) {
867     default:
868         break;
869     case ArgObjectTypeSpecialized::Vme:
870         stream << indentLevel1 << "Vme Metadata:\n";
871         dumpOrNull(arg.metadataSpecialized.vme.mbBlockType, "", stream, indentLevel2);
872         dumpOrNull(arg.metadataSpecialized.vme.sadAdjustMode, "", stream, indentLevel2);
873         dumpOrNull(arg.metadataSpecialized.vme.searchPathType, "", stream, indentLevel2);
874         dumpOrNull(arg.metadataSpecialized.vme.subpixelMode, "", stream, indentLevel2);
875         break;
876     }
877 
878     dumpVecIfNotEmpty(arg.byValMap, "  Data passed by value ", stream, indentLevel1);
879     return stream.str();
880 }
881 
882 } // namespace PatchTokenBinary
883 
884 } // namespace NEO
885