swr/rast: Add general SWTag statistics
[mesa.git] / src / gallium / drivers / swr / rasterizer / codegen / templates / gen_ar_event.hpp
1 /****************************************************************************
2 * Copyright (C) 2016 Intel Corporation. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * @file ${filename}
24 *
25 * @brief Definitions for events. auto-generated file
26 *
27 * DO NOT EDIT
28 *
29 * Generation Command Line:
30 * ${'\n * '.join(cmdline)}
31 *
32 ******************************************************************************/
33 // clang-format off
34 #pragma once
35
36 #include "common/os.h"
37 #include "core/state.h"
38
39 namespace ArchRast
40 {
41 % for name in protos['enum_names']:
42 enum ${name}
43 {<% names = protos['enums'][name]['names'] %>
44 % for i in range(len(names)):
45 ${names[i].lstrip()}
46 % endfor
47 };
48 % endfor
49
50 // Forward decl
51 class EventHandler;
52
53 //////////////////////////////////////////////////////////////////////////
54 /// Event - interface for handling events.
55 //////////////////////////////////////////////////////////////////////////
56 struct Event
57 {
58 Event() {}
59 virtual ~Event() {}
60
61 virtual void Accept(EventHandler* pHandler) const = 0;
62 };
63 % for name in protos['event_names']:
64
65 //////////////////////////////////////////////////////////////////////////
66 /// ${name}Data
67 //////////////////////////////////////////////////////////////////////////
68 #pragma pack(push, 1)
69 struct ${name}Data
70 {<%
71 fields = protos['events'][name]['fields'] %>
72 // Fields
73 % for i in range(len(fields)):
74 % if fields[i]['size'] > 1:
75 ${fields[i]['type']} ${fields[i]['name']}[${fields[i]['size']}];
76 % else:
77 ${fields[i]['type']} ${fields[i]['name']};
78 % endif
79 % endfor
80 };
81 #pragma pack(pop)
82
83 //////////////////////////////////////////////////////////////////////////
84 /// ${name}
85 //////////////////////////////////////////////////////////////////////////
86 struct ${name} : Event
87 {<%
88 fields = protos['events'][name]['fields'] %>
89 ${name}Data data;
90
91 // Constructor
92 ${name}(
93 % for i in range(len(fields)):
94 % if i < len(fields)-1:
95 % if fields[i]['size'] > 1:
96 ${fields[i]['type']}* ${fields[i]['name']},
97 uint32_t ${fields[i]['name']}_size,
98 % else:
99 ${fields[i]['type']} ${fields[i]['name']},
100 % endif
101 % endif
102 % if i == len(fields)-1:
103 % if fields[i]['size'] > 1:
104 ${fields[i]['type']}* ${fields[i]['name']},
105 uint32_t ${fields[i]['name']}_size
106 % else:
107 ${fields[i]['type']} ${fields[i]['name']}
108 % endif
109 % endif
110 % endfor
111 )
112 {
113 % for i in range(len(fields)):
114 % if fields[i]['size'] > 1:
115 % if fields[i]['type'] == 'char':
116 // Copy size of string (null-terminated) followed by string into entire buffer
117 SWR_ASSERT(${fields[i]['name']}_size + 1 < ${fields[i]['size']} - sizeof(uint32_t), "String length must be less than size of char buffer - size(uint32_t)!");
118 memcpy(data.${fields[i]['name']}, &${fields[i]['name']}_size, sizeof(uint32_t));
119 strcpy_s(data.${fields[i]['name']} + sizeof(uint32_t), ${fields[i]['name']}_size + 1, ${fields[i]['name']});
120 % else:
121 memcpy(data.${fields[i]['name']}, ${fields[i]['name']}, ${fields[i]['name']}_size);
122 % endif
123 % else:
124 data.${fields[i]['name']} = ${fields[i]['name']};
125 % endif
126 % endfor
127 }
128
129 virtual void Accept(EventHandler* pHandler) const;
130 };
131 % endfor
132 } // namespace ArchRast
133 // clang-format on